github.com/in4it/ecs-deploy@v0.0.42-0.20240508120354-ed77ff16df25/util/common_test.go (about)

     1  package util
     2  
     3  import "testing"
     4  
     5  func TestFindRule(t *testing.T) {
     6  	a := []string{"1", "2", "3"}
     7  	b := []string{"1", "2", "4"}
     8  	c := RemoveCommonElements(a, b)
     9  	d := RemoveCommonElements(b, a)
    10  	if c[0] != "3" {
    11  		t.Errorf("Unexpected result: %s (wanted %s)", c[0], "3")
    12  	}
    13  	if d[0] != "4" {
    14  		t.Errorf("Unexpected result: %s (wanted %s)", c[0], "3")
    15  	}
    16  }
    17  
    18  func TestInArray(t *testing.T) {
    19  	a := []string{"1", "2", "3"}
    20  	c, i := InArray(a, "2")
    21  	d, y := InArray(a, "4")
    22  	if c == false || i != 1 {
    23  		t.Errorf("Unexpected result: %v (wanted %v)", c, true)
    24  	}
    25  	if d == true || y != -1 {
    26  		t.Errorf("Unexpected result: %v (wanted %v)", d, false)
    27  	}
    28  }