Dragonfly2
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
17package types18
19import (20"testing"21
22"github.com/stretchr/testify/assert"23)
24
25func Test_MakeObjectKeyOfModelFile(t *testing.T) {26tests := []struct {27name string28modelName string29version int30expect func(t *testing.T, s string)31}{32{33name: "make objectKey of model file",34modelName: "foo",35version: 1,36expect: func(t *testing.T, s string) {37assert := assert.New(t)38assert.Equal(s, "foo/1/model.graphdef")39},40},41{42name: "modelName is empty",43modelName: "",44version: 1,45expect: func(t *testing.T, s string) {46assert := assert.New(t)47assert.Equal(s, "/1/model.graphdef")48},49},50}51for _, tc := range tests {52t.Run(tc.name, func(t *testing.T) {53tc.expect(t, MakeObjectKeyOfModelFile(tc.modelName, tc.version))54})55}56}
57
58func Test_MakeObjectKeyOfModelConfigFile(t *testing.T) {59tests := []struct {60name string61modelName string62version int63expect func(t *testing.T, s string)64}{65{66name: "make objectKey of model file",67modelName: "foo",68expect: func(t *testing.T, s string) {69assert := assert.New(t)70assert.Equal(s, "foo/config.pbtxt")71},72},73{74name: "modelName is empty",75modelName: "",76expect: func(t *testing.T, s string) {77assert := assert.New(t)78assert.Equal(s, "/config.pbtxt")79},80},81}82for _, tc := range tests {83t.Run(tc.name, func(t *testing.T) {84tc.expect(t, MakeObjectKeyOfModelConfigFile(tc.modelName))85})86}87}
88