github.com/almamedia/fargate@v0.2.4-0.20220704071213-7b5b3d27c5eb/cmd/port_test.go (about)

     1  package cmd
     2  
     3  import (
     4  	"testing"
     5  )
     6  
     7  func TestEmpty(t *testing.T) {
     8  	var tests = []struct {
     9  		port  Port
    10  		empty bool
    11  	}{
    12  		{Port{}, true},
    13  		{Port{80, ""}, true},
    14  		{Port{0, "HTTP"}, true},
    15  		{Port{80, "HTTP"}, false},
    16  	}
    17  
    18  	for _, test := range tests {
    19  		if test.port.Empty() != test.empty {
    20  			t.Errorf("expected port %s empty == %t, got %t", test.port, test.empty, test.port.Empty())
    21  		}
    22  	}
    23  }
    24  
    25  func TestString(t *testing.T) {
    26  	var tests = []struct {
    27  		port Port
    28  		out  string
    29  	}{
    30  		{Port{}, ""},
    31  		{Port{80, ""}, ""},
    32  		{Port{0, "HTTP"}, ""},
    33  		{Port{80, "HTTP"}, "HTTP:80"},
    34  		{Port{25, "TCP"}, "TCP:25"},
    35  	}
    36  
    37  	for _, test := range tests {
    38  		if test.port.String() != test.out {
    39  			t.Errorf("expected port %s == %s, got %s", test.port, test.out, test.port.String())
    40  		}
    41  	}
    42  }