From 4ad9ffaff8e268a8acd7aa7358fd888eefa0aa75 Mon Sep 17 00:00:00 2001 From: Shreya2005-2005 Date: Sat, 2 May 2026 06:34:29 +0000 Subject: [PATCH] test: add unit tests for remove Signed-off-by: Shreya2005-2005 --- pkg/unikontainers/remove_test.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 pkg/unikontainers/remove_test.go diff --git a/pkg/unikontainers/remove_test.go b/pkg/unikontainers/remove_test.go new file mode 100644 index 00000000..a549a72c --- /dev/null +++ b/pkg/unikontainers/remove_test.go @@ -0,0 +1,28 @@ +package unikontainers + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// Tests for remove() - removes element from a string slice by index +func TestRemove(t *testing.T) { + t.Run("remove first element", func(t *testing.T) { + s := []string{"a", "b", "c"} + result := remove(s, 0) + assert.Len(t, result, 2) + }) + + t.Run("remove middle element", func(t *testing.T) { + s := []string{"a", "b", "c"} + result := remove(s, 1) + assert.Len(t, result, 2) + }) + + t.Run("remove only element", func(t *testing.T) { + s := []string{"a"} + result := remove(s, 0) + assert.Len(t, result, 0) + }) +}