@@ -126,7 +126,10 @@ func TestTagList(t *testing.T) {
126126 AssertEquals (true , tags .Contains ("TWO" ), t )
127127 AssertEquals ("TWO" , tags [1 ], t )
128128
129- tags .Remove ("ONE" )
129+ err := tags .Remove ("ONE" )
130+ if err == nil {
131+ t .Fatal ("removing tag that doesn't exist should have failed" )
132+ }
130133 AssertEquals ("one" , tags [0 ], t )
131134 AssertEquals (true , tags .Contains ("TWO" ), t )
132135}
@@ -476,23 +479,27 @@ func TestTagList_Add(t *testing.T) {
476479
477480func TestTagList_Delete (t * testing.T ) {
478481 type test struct {
479- v string
480- a TagList
481- shouldBe TagList
482+ v string
483+ a TagList
484+ shouldBe TagList
485+ shouldFail bool
482486 }
483487
484488 tests := []test {
485- {v : "A" , a : TagList {}, shouldBe : TagList {}},
489+ {v : "A" , a : TagList {}, shouldBe : TagList {}, shouldFail : true },
486490 {v : "A" , a : TagList {"A" }, shouldBe : TagList {}},
487- {v : "a" , a : TagList {"A" }, shouldBe : TagList {"A" }},
488- {v : "a:Hello" , a : TagList {"a:hello" }, shouldBe : TagList {"a:hello" }},
489- {v : "a:a" , a : TagList {"a:A" }, shouldBe : TagList {"a:A" }},
491+ {v : "a" , a : TagList {"A" }, shouldBe : TagList {"A" }, shouldFail : true },
492+ {v : "a:Hello" , a : TagList {"a:hello" }, shouldBe : TagList {"a:hello" }, shouldFail : true },
493+ {v : "a:a" , a : TagList {"a:A" }, shouldBe : TagList {"a:A" }, shouldFail : true },
490494 }
491495
492496 for idx , test := range tests {
493- test .a .Remove (test .v )
497+ err := test .a .Remove (test .v )
498+ if test .shouldFail && err == nil {
499+ t .Fatalf ("[%d] expected delete to fail: %v" , idx , test .a )
500+ }
494501 if ! test .a .Equals (& test .shouldBe ) {
495- t .Errorf ("[%d] expected lists to be equal: %v" , idx , test .a )
502+ t .Fatalf ("[%d] expected lists to be equal: %v" , idx , test .a )
496503 }
497504 }
498505}
0 commit comments