@@ -126,7 +126,10 @@ func TestTagList(t *testing.T) {
126
126
AssertEquals (true , tags .Contains ("TWO" ), t )
127
127
AssertEquals ("TWO" , tags [1 ], t )
128
128
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
+ }
130
133
AssertEquals ("one" , tags [0 ], t )
131
134
AssertEquals (true , tags .Contains ("TWO" ), t )
132
135
}
@@ -476,23 +479,27 @@ func TestTagList_Add(t *testing.T) {
476
479
477
480
func TestTagList_Delete (t * testing.T ) {
478
481
type test struct {
479
- v string
480
- a TagList
481
- shouldBe TagList
482
+ v string
483
+ a TagList
484
+ shouldBe TagList
485
+ shouldFail bool
482
486
}
483
487
484
488
tests := []test {
485
- {v : "A" , a : TagList {}, shouldBe : TagList {}},
489
+ {v : "A" , a : TagList {}, shouldBe : TagList {}, shouldFail : true },
486
490
{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 },
490
494
}
491
495
492
496
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
+ }
494
501
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 )
496
503
}
497
504
}
498
505
}
0 commit comments