From f5f1e23dba10c1a2dc3d90afb2c8d0dec70b2ebc Mon Sep 17 00:00:00 2001 From: Kaushal Subedi Date: Mon, 26 Oct 2015 20:43:54 -0600 Subject: added processing of go files without using ast --- main_test.go | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'main_test.go') 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 { -- cgit v1.2.3