diff options
| author | Kaushal Subedi | 2015-10-26 20:43:54 -0600 |
|---|---|---|
| committer | Kaushal Subedi | 2015-10-26 20:43:54 -0600 |
| commit | f5f1e23dba10c1a2dc3d90afb2c8d0dec70b2ebc (patch) | |
| tree | a6fed366913dbd2b94149f121ddd339c7a69f1e2 /main_test.go | |
| parent | d40ae98795e704d5931ae2d0124181ce72fab922 (diff) | |
| download | gomove-f5f1e23dba10c1a2dc3d90afb2c8d0dec70b2ebc.tar.bz2 | |
added processing of go files without using ast
Diffstat (limited to 'main_test.go')
| -rw-r--r-- | main_test.go | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/main_test.go b/main_test.go index b0ede2f..17a8219 100644 --- a/main_test.go +++ b/main_test.go @@ -7,12 +7,30 @@ import ( "testing" ) -func TestApp(t *testing.T) { +func TestAppAST(t *testing.T) { fileContent := "package testing\n\nimport \"fmt\"\n\nfunc HelloWorld() {\nfmt.Println(\"Hello World!\")\n}\n" ioutil.WriteFile("hello.go", []byte(fileContent), os.ModePerm) - ProcessFile("hello.go", "fmt", "replacedImport") + ProcessFileAST("hello.go", "fmt", "replacedImport") + + result, err := ioutil.ReadFile("hello.go") + if err != nil { + t.Error("Failed to read written file.") + } + + if !strings.Contains(string(result), "replacedImport") { + t.Error("Got different results") + } + os.Remove("hello.go") +} + +func TestAppNative(t *testing.T) { + fileContent := "package testing\n\nimport \"fmt\"\n\nfunc HelloWorld() {\nfmt.Println(\"Hello World!\")\n}\n" + + ioutil.WriteFile("hello.go", []byte(fileContent), os.ModePerm) + + ProcessFileNative("hello.go", "fmt", "replacedImport") result, err := ioutil.ReadFile("hello.go") if err != nil { |
