Select Git revision
db_test.go

Richard T. Carback III authored
db_test.go 1.14 KiB
///////////////////////////////////////////////////////////////////////////////
// Copyright © 2020 xx network SEZC //
// //
// Use of this source code is governed by a license that can be found in the //
// LICENSE file //
///////////////////////////////////////////////////////////////////////////////
package conf
import (
"gitlab.com/xx_network/primitives/utils"
"gopkg.in/yaml.v2"
"reflect"
"testing"
)
var ExpectedDatabase = Database{
Name: "name",
Username: "username",
Password: "password",
Address: "127.0.0.1:80",
}
// This test checks that unmarshalling the params.yaml file
// has the expected Database object.
func TestDB_UnmarshallingFileEqualsExpected(t *testing.T) {
buf, _ := utils.ReadFile("./params.yaml")
actual := Params{}
err := yaml.Unmarshal(buf, &actual)
if err != nil {
t.Errorf("Unable to decode into struct, %v", err)
}
if !reflect.DeepEqual(ExpectedDatabase, actual.Database) {
t.Errorf("Database object did not match value")
}
}