aboutsummaryrefslogtreecommitdiffstats
path: root/main_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'main_test.go')
-rw-r--r--main_test.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/main_test.go b/main_test.go
new file mode 100644
index 0000000..b0ede2f
--- /dev/null
+++ b/main_test.go
@@ -0,0 +1,26 @@
+package main
+
+import (
+ "io/ioutil"
+ "os"
+ "strings"
+ "testing"
+)
+
+func TestApp(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")
+
+ 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")
+}