github.com/konsorten/ktn-build-info@v1.0.11/ver/working_dir_test.go (about) 1 package ver 2 3 import ( 4 "os" 5 "testing" 6 7 log "github.com/sirupsen/logrus" 8 ) 9 10 func TestTryReadWorkingDir(t *testing.T) { 11 log.SetLevel(log.DebugLevel) 12 13 // change to test data dir 14 currDir, _ := os.Getwd() 15 os.Chdir("examples/npm") 16 defer os.Chdir(currDir) 17 18 // read version information 19 found, err := TryReadFromWorkingDirectory() 20 21 if err != nil { 22 t.Fatalf("Failed to read version info: %v", err) 23 } 24 25 if found == nil { 26 t.Fatalf("%v not found", VersionInfoYamlFilename) 27 } 28 29 if found.Name != "npm" { 30 t.Fatal("Wrong project name") 31 } 32 }