github.com/MealCraft/glide@v0.13.4/action/name_test.go (about) 1 package action 2 3 import ( 4 "bytes" 5 "os" 6 "testing" 7 8 "github.com/Masterminds/glide/msg" 9 ) 10 11 func TestName(t *testing.T) { 12 var buf bytes.Buffer 13 msg.Default.PanicOnDie = true 14 ostdout := msg.Default.Stdout 15 msg.Default.Stdout = &buf 16 wd, _ := os.Getwd() 17 if err := os.Chdir("../testdata/name"); err != nil { 18 t.Errorf("Failed to change directory: %s", err) 19 } 20 Name() 21 if buf.String() != "technosophos.com/x/foo\n" { 22 t.Errorf("Unexpectedly got name %q", buf.String()) 23 } 24 msg.Default.Stdout = ostdout 25 os.Chdir(wd) 26 }