github.com/turtlemonvh/terraform@v0.6.9-0.20151204001754-8e40b6b855e8/config/string_list_test.go (about)

     1  package config
     2  
     3  import (
     4  	"reflect"
     5  	"testing"
     6  )
     7  
     8  func TestStringList_slice(t *testing.T) {
     9  	expected := []string{"apple", "banana", "pear"}
    10  	l := NewStringList(expected)
    11  	actual := l.Slice()
    12  
    13  	if !reflect.DeepEqual(expected, actual) {
    14  		t.Fatalf("Expected %q, got %q", expected, actual)
    15  	}
    16  }
    17  
    18  func TestStringList_element(t *testing.T) {
    19  	list := []string{"apple", "banana", "pear"}
    20  	l := NewStringList(list)
    21  	actual := l.Element(1)
    22  
    23  	expected := "banana"
    24  
    25  	if actual != expected {
    26  		t.Fatalf("Expected 2nd element from %q to be %q, got %q",
    27  			list, expected, actual)
    28  	}
    29  }
    30  
    31  func TestStringList_empty_slice(t *testing.T) {
    32  	expected := []string{}
    33  	l := NewStringList(expected)
    34  	actual := l.Slice()
    35  
    36  	if !reflect.DeepEqual(expected, actual) {
    37  		t.Fatalf("Expected %q, got %q", expected, actual)
    38  	}
    39  }
    40  
    41  func TestStringList_empty_slice_length(t *testing.T) {
    42  	list := []string{}
    43  	l := NewStringList([]string{})
    44  	actual := l.Length()
    45  
    46  	expected := 0
    47  
    48  	if actual != expected {
    49  		t.Fatalf("Expected length of %q to be %d, got %d",
    50  			list, expected, actual)
    51  	}
    52  }