Dragonfly2

Форк
0
/
model_test.go 
87 строк · 2.1 Кб
1
/*
2
 *     Copyright 2023 The Dragonfly Authors
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *      http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16

17
package types
18

19
import (
20
	"testing"
21

22
	"github.com/stretchr/testify/assert"
23
)
24

25
func Test_MakeObjectKeyOfModelFile(t *testing.T) {
26
	tests := []struct {
27
		name      string
28
		modelName string
29
		version   int
30
		expect    func(t *testing.T, s string)
31
	}{
32
		{
33
			name:      "make objectKey of model file",
34
			modelName: "foo",
35
			version:   1,
36
			expect: func(t *testing.T, s string) {
37
				assert := assert.New(t)
38
				assert.Equal(s, "foo/1/model.graphdef")
39
			},
40
		},
41
		{
42
			name:      "modelName is empty",
43
			modelName: "",
44
			version:   1,
45
			expect: func(t *testing.T, s string) {
46
				assert := assert.New(t)
47
				assert.Equal(s, "/1/model.graphdef")
48
			},
49
		},
50
	}
51
	for _, tc := range tests {
52
		t.Run(tc.name, func(t *testing.T) {
53
			tc.expect(t, MakeObjectKeyOfModelFile(tc.modelName, tc.version))
54
		})
55
	}
56
}
57

58
func Test_MakeObjectKeyOfModelConfigFile(t *testing.T) {
59
	tests := []struct {
60
		name      string
61
		modelName string
62
		version   int
63
		expect    func(t *testing.T, s string)
64
	}{
65
		{
66
			name:      "make objectKey of model file",
67
			modelName: "foo",
68
			expect: func(t *testing.T, s string) {
69
				assert := assert.New(t)
70
				assert.Equal(s, "foo/config.pbtxt")
71
			},
72
		},
73
		{
74
			name:      "modelName is empty",
75
			modelName: "",
76
			expect: func(t *testing.T, s string) {
77
				assert := assert.New(t)
78
				assert.Equal(s, "/config.pbtxt")
79
			},
80
		},
81
	}
82
	for _, tc := range tests {
83
		t.Run(tc.name, func(t *testing.T) {
84
			tc.expect(t, MakeObjectKeyOfModelConfigFile(tc.modelName))
85
		})
86
	}
87
}
88

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.