File size: 858 Bytes
f03b0c4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package tests

import (
	"reflect"
	"testing"

	proxy "tebakaja_lb_proxy/proxy"
)

func IsStringReflect(x interface{}) bool {
	return reflect.TypeOf(x).Kind() == reflect.String
}

func IsStringTypeAssertion(x interface{}) bool {
	_, ok := x.(string)
	return ok
}

func TestGetEndpointByRestService(t *testing.T) {
	tests := []struct {
		service string
		want    bool
	}{
		{"crypto", true},
		{"national", true},
		{"stock", true},
	}

	for _, tt := range tests {
		t.Run(tt.service, func(t *testing.T) {
			endpoint := proxy.GetEndpointByRestService(tt.service)

			if got := IsStringReflect(endpoint); got != tt.want {
				t.Errorf("IsStringReflect(%v) = %v, want %v", endpoint, got, tt.want)
			}

			if got := IsStringTypeAssertion(endpoint); got != tt.want {
				t.Errorf("IsStringTypeAssertion(%v) = %v, want %v", endpoint, got, tt.want)
			}
		})
	}
}