Files
sablier/pkg/arrays/remove_elements_test.go
Alexis Couvreur 52a7d2195f feat(providers): add provider.auto-stop-on-startup argument (#346)
This feature adds the capability to stop unregistered running instances upon startup.

Previously, you had to stop running instances manually or issue an initial request that will shut down instances afterwards.

With this change, all discovered instances will be shutdown. They need to be registered using labels. E.g.: sablier.enable=true

Fixes #153
2024-07-04 12:06:21 -04:00

31 lines
1.4 KiB
Go

package arrays
import (
"reflect"
"testing"
)
func TestRemoveElements(t *testing.T) {
tests := []struct {
allElements []string
elementsToRemove []string
expected []string
}{
{[]string{"apple", "banana", "cherry", "date", "fig", "grape"}, []string{"banana", "date", "grape"}, []string{"apple", "cherry", "fig"}},
{[]string{"apple", "banana", "cherry"}, []string{"date", "fig", "grape"}, []string{"apple", "banana", "cherry"}}, // No elements to remove are present
{[]string{"apple", "banana", "cherry", "date"}, []string{}, []string{"apple", "banana", "cherry", "date"}}, // No elements to remove
{[]string{}, []string{"apple", "banana", "cherry"}, []string{}}, // Empty allElements slice
{[]string{"apple", "banana", "banana", "cherry", "cherry", "date"}, []string{"banana", "cherry"}, []string{"apple", "date"}}, // Duplicate elements in allElements
{[]string{"apple", "apple", "apple", "apple"}, []string{"apple"}, []string{}}, // All elements are removed
}
for _, tt := range tests {
t.Run("", func(t *testing.T) {
result := RemoveElements(tt.allElements, tt.elementsToRemove)
if !reflect.DeepEqual(result, tt.expected) {
t.Errorf("RemoveElements(%v, %v) = %v; want %v", tt.allElements, tt.elementsToRemove, result, tt.expected)
}
})
}
}