-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: kpango <i.can.feel.gravity@gmail.com>
- Loading branch information
kpango
committed
Jun 25, 2020
1 parent
f6c2444
commit 032a1df
Showing
88 changed files
with
46,719 additions
and
338 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
// | ||
// Copyright (C) 2019-2020 Vdaas.org Vald team ( kpango, rinx, kmrmt ) | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
// Package setting stores all server application settings | ||
package config | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
|
||
"github.com/vdaas/vald/internal/errors" | ||
"go.uber.org/goleak" | ||
) | ||
|
||
func TestNewConfig(t *testing.T) { | ||
type args struct { | ||
path string | ||
} | ||
type want struct { | ||
wantCfg *Data | ||
err error | ||
} | ||
type test struct { | ||
name string | ||
args args | ||
want want | ||
checkFunc func(want, *Data, error) error | ||
beforeFunc func(args) | ||
afterFunc func(args) | ||
} | ||
defaultCheckFunc := func(w want, gotCfg *Data, err error) error { | ||
if !errors.Is(err, w.err) { | ||
return errors.Errorf("got error = %v, want %v", err, w.err) | ||
} | ||
if !reflect.DeepEqual(gotCfg, w.wantCfg) { | ||
return errors.Errorf("got = %v, want %v", gotCfg, w.wantCfg) | ||
} | ||
return nil | ||
} | ||
tests := []test{ | ||
// TODO test cases | ||
/* | ||
{ | ||
name: "test_case_1", | ||
args: args { | ||
path: "", | ||
}, | ||
want: want{}, | ||
checkFunc: defaultCheckFunc, | ||
}, | ||
*/ | ||
|
||
// TODO test cases | ||
/* | ||
func() test { | ||
return test { | ||
name: "test_case_2", | ||
args: args { | ||
path: "", | ||
}, | ||
want: want{}, | ||
checkFunc: defaultCheckFunc, | ||
} | ||
}(), | ||
*/ | ||
} | ||
|
||
for _, test := range tests { | ||
t.Run(test.name, func(tt *testing.T) { | ||
defer goleak.VerifyNone(tt) | ||
if test.beforeFunc != nil { | ||
test.beforeFunc(test.args) | ||
} | ||
if test.afterFunc != nil { | ||
defer test.afterFunc(test.args) | ||
} | ||
if test.checkFunc == nil { | ||
test.checkFunc = defaultCheckFunc | ||
} | ||
|
||
gotCfg, err := NewConfig(test.args.path) | ||
if err := test.checkFunc(test.want, gotCfg, err); err != nil { | ||
tt.Errorf("error = %v", err) | ||
} | ||
|
||
}) | ||
} | ||
} |
Oops, something went wrong.