forked from facebookincubator/go2chef
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig_test.go
More file actions
32 lines (25 loc) · 768 Bytes
/
config_test.go
File metadata and controls
32 lines (25 loc) · 768 Bytes
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
package go2chef
/*
Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
*/
import (
"github.com/spf13/pflag"
"testing"
)
type DummyConfigSource struct{}
func (d *DummyConfigSource) InitFlags(set *pflag.FlagSet) {}
func (d *DummyConfigSource) ReadConfig() (map[string]interface{}, error) {
return make(map[string]interface{}), nil
}
var _ ConfigSource = &DummyConfigSource{}
func TestConfigSourceRegistry(t *testing.T) {
RegisterConfigSource("dupe", &DummyConfigSource{})
if !doesFunctionPanic(func() {
RegisterConfigSource("dupe", nil)
}) {
t.Fatalf("RegisterConfigSource does not panic on duplicate")
}
if cs := GetConfigSource("dupe"); cs == nil {
t.Errorf("failed to get config source `dupe` despite it being registered")
}
}