gobot.io/x/gobot/v2@v2.1.0/gobottest/gobottest_test.go (about) 1 package gobottest 2 3 import "testing" 4 5 func TestAssert(t *testing.T) { 6 err := "" 7 errFunc = func(t *testing.T, message string) { 8 err = message 9 } 10 11 Assert(t, 1, 1) 12 if err != "" { 13 t.Errorf("Assert failed: 1 should equal 1") 14 } 15 16 Assert(t, 1, 2) 17 if err != `gobottest_test.go:16: 1 - "int", should equal, 2 - "int"` { 18 t.Errorf("Assert failed: 1 should not equal 2") 19 } 20 } 21 22 func TestRefute(t *testing.T) { 23 err := "" 24 errFunc = func(t *testing.T, message string) { 25 err = message 26 } 27 28 Refute(t, 1, 2) 29 if err != "" { 30 t.Errorf("Refute failed: 1 should not be 2") 31 } 32 33 Refute(t, 1, 1) 34 if err != `gobottest_test.go:33: 1 - "int", should not equal, 1 - "int"` { 35 t.Errorf("Refute failed: 1 should not be 1") 36 } 37 } 38 39 func TestExecCommand(t *testing.T) { 40 val := ExecCommand("echo", "hello") 41 Refute(t, val, nil) 42 }