@@ -64,6 +64,53 @@ func (s *ActionStateToMetastateSuite) TestContainsElement() {
6464 })
6565}
6666
67+ func (s * ActionStateToMetastateSuite ) TestRemoveElement () {
68+ s .T ().Run ("removing an existing element" , func (t * testing.T ) {
69+ fxt := tf .NewTestFixture (t , s .DB , tf .CreateWorkItemEnvironment ())
70+ action := ActionStateToMetaState {
71+ Db : s .GormDB ,
72+ Ctx : s .Ctx ,
73+ UserID : & fxt .Identities [0 ].ID ,
74+ }
75+ // there is no other way of creating an []interface{}.
76+ // but we have plenty of memory, so be it.
77+ var a []interface {}
78+ a = append (a , 0 )
79+ a = append (a , 1 )
80+ a = append (a , 2 )
81+ a = append (a , 3 )
82+ a = append (a , 2 )
83+ a = action .removeElement (a , 2 )
84+ require .Len (t , a , 3 )
85+ require .False (t , action .contains (a , 2 ))
86+ a = action .removeElement (a , 1 )
87+ require .Len (t , a , 2 )
88+ require .False (t , action .contains (a , 1 ))
89+ })
90+ s .T ().Run ("removing a non-existing element" , func (t * testing.T ) {
91+ fxt := tf .NewTestFixture (t , s .DB , tf .CreateWorkItemEnvironment ())
92+ action := ActionStateToMetaState {
93+ Db : s .GormDB ,
94+ Ctx : s .Ctx ,
95+ UserID : & fxt .Identities [0 ].ID ,
96+ }
97+ // there is no other way of creating an []interface{}.
98+ // but we have plenty of memory, so be it.
99+ var a []interface {}
100+ a = append (a , 0 )
101+ a = append (a , 1 )
102+ a = append (a , 2 )
103+ a = append (a , 3 )
104+ a = append (a , 2 )
105+ a = action .removeElement (a , 4 )
106+ require .Len (t , a , 5 )
107+ require .True (t , action .contains (a , 0 ))
108+ require .True (t , action .contains (a , 1 ))
109+ require .True (t , action .contains (a , 2 ))
110+ require .True (t , action .contains (a , 3 ))
111+ })
112+ }
113+
67114func (s * ActionStateToMetastateSuite ) TestActionExecution () {
68115 // Note on the fixture: by default, the created board is attached to the type group
69116 // with the same index. The columns on each board are as follows:
0 commit comments