gobot.io/x/gobot/v2@v2.1.0/commander_test.go (about)

     1  package gobot
     2  
     3  import (
     4  	"testing"
     5  
     6  	"gobot.io/x/gobot/v2/gobottest"
     7  )
     8  
     9  func TestCommaner(t *testing.T) {
    10  	c := NewCommander()
    11  	c.AddCommand("test", func(map[string]interface{}) interface{} {
    12  		return "hi"
    13  	})
    14  
    15  	if _, ok := c.Commands()["test"]; !ok {
    16  		t.Errorf("Could not add command to list of Commands")
    17  	}
    18  
    19  	command := c.Command("test")
    20  	gobottest.Refute(t, command, nil)
    21  
    22  	command = c.Command("booyeah")
    23  	gobottest.Assert(t, command, (func(map[string]interface{}) interface{})(nil))
    24  }