github.com/go-graphite/carbonapi@v0.17.0/cmd/mockbackend/e2etesting_test.go (about) 1 package main 2 3 import ( 4 "strconv" 5 "testing" 6 ) 7 8 func Test_resortErr(t *testing.T) { 9 tests := []struct { 10 errStr string 11 want string 12 }{ 13 { 14 errStr: "b: connection refused\na: connection refused\n", 15 want: "a: connection refused\nb: connection refused\n", 16 }, 17 { 18 errStr: "a: connection refused\nb: connection refused\n", 19 want: "a: connection refused\nb: connection refused\n", 20 }, 21 { 22 errStr: "", 23 want: "", 24 }, 25 { 26 errStr: "\n", 27 want: "\n", 28 }, 29 } 30 for i, tt := range tests { 31 t.Run(strconv.Itoa(i), func(t *testing.T) { 32 if got := resortErr(tt.errStr); got != tt.want { 33 t.Errorf("resortErr(%q) = %q, want %q", tt.errStr, got, tt.want) 34 } 35 }) 36 } 37 }