github.com/chasestarr/deis@v1.13.5-0.20170519182049-1d9e59fbdbfc/client/controller/api/domains_test.go (about)

     1  package api
     2  
     3  import (
     4  	"sort"
     5  	"testing"
     6  )
     7  
     8  func TestDomainsSorted(t *testing.T) {
     9  	domains := Domains{
    10  		{"Alpha", "", "gamma.example.com", "", ""},
    11  		{"Alpha", "", "alpha1.example.com", "", ""},
    12  		{"Alpha", "", "zulu.example.com", "", ""},
    13  		{"Alpha", "", "delta.example.com", "", ""},
    14  	}
    15  
    16  	sort.Sort(domains)
    17  	expectedDomains := []string{"alpha1.example.com", "delta.example.com", "gamma.example.com", "zulu.example.com"}
    18  
    19  	for i, domain := range domains {
    20  		if expectedDomains[i] != domain.Domain {
    21  			t.Errorf("Expected domains to be sorted %v, Got %v at index %v", expectedDomains[i], domain.Domain, i)
    22  		}
    23  	}
    24  }