@cryptotaxi247 / kubo / commits / c054fb365

commands: Added simple Command#Resolve test

Matt Bell committed Oct 15, 2014 at 17:09 UTC c054fb3655776881166672a3feec9035ae4a8d5f
1 file changed +21
commands/command_test.go
+21
@@ -136,3 +136,24 @@ func TestRegistration(t *testing.T) {
136 t.Error("Should have failed (option name collision with global options)")
137 }
138 }
139 +
140 +func TestResolving(t *testing.T) {
141 + cmd := &Command{}
142 + cmdA := &Command{}
143 + cmdB := &Command{}
144 + cmdB2 := &Command{}
145 + cmdC := &Command{}
146 +
147 + cmd.Register("a", cmdA)
148 + cmdA.Register("B", cmdB2)
149 + cmdA.Register("b", cmdB)
150 + cmdB.Register("c", cmdC)
151 +
152 + cmds, err := cmd.Resolve([]string{"a","b","c"})
153 + if err != nil {
154 + t.Error(err)
155 + }
156 + if len(cmds) != 4 || cmds[0] != cmd || cmds[1] != cmdA || cmds[2] != cmdB || cmds[3] != cmdC {
157 + t.Error("Returned command path is different than expected", cmds)
158 + }
159 +}
\ No newline at end of file