mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-26 00:41:27 -06:00
69 lines
1.1 KiB
Go
69 lines
1.1 KiB
Go
package main
|
|
|
|
import (
|
|
"path/filepath"
|
|
"reflect"
|
|
"testing"
|
|
)
|
|
|
|
// This is the directory where our test fixtures are.
|
|
const fixtureDir = "./test-fixtures"
|
|
|
|
func TestLoadConfig(t *testing.T) {
|
|
c, err := LoadConfig(filepath.Join(fixtureDir, "config"))
|
|
if err != nil {
|
|
t.Fatalf("err: %s", err)
|
|
}
|
|
|
|
expected := &Config{
|
|
Providers: map[string]string{
|
|
"aws": "foo",
|
|
"do": "bar",
|
|
},
|
|
}
|
|
|
|
if !reflect.DeepEqual(c, expected) {
|
|
t.Fatalf("bad: %#v", c)
|
|
}
|
|
}
|
|
|
|
func TestConfig_Merge(t *testing.T) {
|
|
c1 := &Config{
|
|
Providers: map[string]string{
|
|
"foo": "bar",
|
|
"bar": "blah",
|
|
},
|
|
Provisioners: map[string]string{
|
|
"local": "local",
|
|
"remote": "bad",
|
|
},
|
|
}
|
|
|
|
c2 := &Config{
|
|
Providers: map[string]string{
|
|
"bar": "baz",
|
|
"baz": "what",
|
|
},
|
|
Provisioners: map[string]string{
|
|
"remote": "remote",
|
|
},
|
|
}
|
|
|
|
expected := &Config{
|
|
Providers: map[string]string{
|
|
"foo": "bar",
|
|
"bar": "baz",
|
|
"baz": "what",
|
|
},
|
|
Provisioners: map[string]string{
|
|
"local": "local",
|
|
"remote": "remote",
|
|
},
|
|
}
|
|
|
|
actual := c1.Merge(c2)
|
|
if !reflect.DeepEqual(actual, expected) {
|
|
t.Fatalf("bad: %#v", actual)
|
|
}
|
|
}
|