[hot-fix] fix tests
parent
fcf79b2f5a
commit
ffdc7b70f0
|
|
@ -29,17 +29,18 @@ func NewInterpreter(s string) *Interpreter {
|
|||
|
||||
// ClearNS clears the current namespace if any.
|
||||
func (c *Interpreter) ClearNS() {
|
||||
if !c.HasNS() {
|
||||
return
|
||||
}
|
||||
if ons, ok := c.NSArg(); ok {
|
||||
c.Reset(strings.TrimSpace(strings.Replace(c.line, " "+ons, "", 1)))
|
||||
}
|
||||
c.SwitchNS(client.BlankNamespace)
|
||||
}
|
||||
|
||||
// SwitchNS replaces the current namespace with the provided one.
|
||||
func (c *Interpreter) SwitchNS(ns string) {
|
||||
c.args[nsKey] = ns
|
||||
if ons, ok := c.NSArg(); ok && ons != client.BlankNamespace {
|
||||
c.Reset(strings.TrimSpace(strings.Replace(c.line, " "+ons, " "+ns, 1)))
|
||||
return
|
||||
}
|
||||
if ns != client.BlankNamespace {
|
||||
c.Reset(strings.TrimSpace(c.line) + " " + ns)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Interpreter) grok() {
|
||||
|
|
|
|||
|
|
@ -85,10 +85,15 @@ func TestSwitchNS(t *testing.T) {
|
|||
}{
|
||||
"empty": {},
|
||||
|
||||
"blank": {
|
||||
cmd: "pod fred",
|
||||
e: "pod",
|
||||
},
|
||||
|
||||
"no-op": {
|
||||
cmd: "pod fred",
|
||||
ns: "blee",
|
||||
e: "pod blee",
|
||||
ns: "fred",
|
||||
e: "pod fred",
|
||||
},
|
||||
|
||||
"no-ns": {
|
||||
|
|
@ -97,8 +102,20 @@ func TestSwitchNS(t *testing.T) {
|
|||
e: "pod blee",
|
||||
},
|
||||
|
||||
"happy": {
|
||||
cmd: "pod app=blee @zorg fred",
|
||||
"full-ns": {
|
||||
cmd: "pod app=blee fred @zorg",
|
||||
ns: "blee",
|
||||
e: "pod app=blee blee @zorg",
|
||||
},
|
||||
|
||||
"full--repeat-ns": {
|
||||
cmd: "pod app=zorg zorg @zorg",
|
||||
ns: "blee",
|
||||
e: "pod app=zorg blee @zorg",
|
||||
},
|
||||
|
||||
"full-no-ns": {
|
||||
cmd: "pod app=blee @zorg",
|
||||
ns: "blee",
|
||||
e: "pod app=blee @zorg blee",
|
||||
},
|
||||
|
|
@ -121,7 +138,7 @@ func TestClearNS(t *testing.T) {
|
|||
}{
|
||||
"empty": {},
|
||||
|
||||
"no-op": {
|
||||
"has-ns": {
|
||||
cmd: "pod fred",
|
||||
e: "pod",
|
||||
},
|
||||
|
|
@ -131,10 +148,15 @@ func TestClearNS(t *testing.T) {
|
|||
e: "pod",
|
||||
},
|
||||
|
||||
"happy": {
|
||||
"full-repeat-ns": {
|
||||
cmd: "pod app=blee @zorg zorg",
|
||||
e: "pod app=blee @zorg",
|
||||
},
|
||||
|
||||
"full-no-ns": {
|
||||
cmd: "pod app=blee @zorg",
|
||||
e: "pod app=blee @zorg",
|
||||
},
|
||||
}
|
||||
|
||||
for k := range uu {
|
||||
|
|
|
|||
Loading…
Reference in New Issue