File: helpers_test.go

package info (click to toggle)
golang-github-grpc-ecosystem-grpc-gateway.v2 2.11.3-2
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 6,148 kB
  • sloc: javascript: 352; makefile: 136; sh: 26
file content (66 lines) | stat: -rw-r--r-- 1,627 bytes parent folder | download | duplicates (2)
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package genopenapi

import (
	"reflect"
	"testing"
)

func Test_getUniqueFields(t *testing.T) {
	type args struct {
		schemaFieldsRequired []string
		fieldsRequired       []string
	}
	var tests = []struct {
		name string
		args args
		want []string
	}{
		{
			name: "test_1",
			args: args{
				schemaFieldsRequired: []string{"Field_1", "Field_2", "Field_3"},
				fieldsRequired:       []string{"Field_2"},
			},
			want: []string{"Field_1", "Field_3"},
		},
		{
			name: "test_2",
			args: args{
				schemaFieldsRequired: []string{"Field_1", "Field_2", "Field_3"},
				fieldsRequired:       []string{"Field_3"},
			},
			want: []string{"Field_1", "Field_2"},
		},
		{
			name: "test_3",
			args: args{
				schemaFieldsRequired: []string{"Field_1", "Field_2", "Field_3"},
				fieldsRequired:       []string{"Field_4"},
			},
			want: []string{"Field_1", "Field_2", "Field_3"},
		},
		{
			name: "test_4",
			args: args{
				schemaFieldsRequired: []string{"Field_1", "Field_2", "Field_3", "Field_4", "Field_5", "Field_6"},
				fieldsRequired:       []string{"Field_6", "Field_4", "Field_1"},
			},
			want: []string{"Field_2", "Field_3", "Field_5"},
		},
		{
			name: "test_5",
			args: args{
				schemaFieldsRequired: []string{"Field_1", "Field_2", "Field_3"},
				fieldsRequired:       []string{},
			},
			want: []string{"Field_1", "Field_2", "Field_3"},
		},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			if got := getUniqueFields(tt.args.schemaFieldsRequired, tt.args.fieldsRequired); !reflect.DeepEqual(got, tt.want) {
				t.Errorf("getUniqueFields() = %v, want %v", got, tt.want)
			}
		})
	}
}