This repository has been archived by the owner on Jul 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
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: Jason McCallister <jason@craftcms.com>
- Loading branch information
1 parent
7e2a5c7
commit 46bfedc
Showing
4 changed files
with
30 additions
and
27 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,36 @@ | ||
package config | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
) | ||
|
||
func TestReadFile(t *testing.T) { | ||
type args struct { | ||
file string | ||
defaults map[string]interface{} | ||
// Arrange | ||
file := "./testdata/nitro-full.yaml" | ||
overrides := map[string]interface{}{ | ||
"cpu": 2, | ||
"disk": "20G", | ||
"memory": "2G", | ||
} | ||
tests := []struct { | ||
name string | ||
args args | ||
want []string | ||
wantErr bool | ||
}{ | ||
{ | ||
name:"", | ||
}, | ||
|
||
// Act | ||
config, err := ReadFile(file, overrides) | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
got, err := ReadFile(tt.args.file, tt.args.defaults) | ||
if (err != nil) != tt.wantErr { | ||
t.Errorf("ReadFile() error = %v, wantErr %v", err, tt.wantErr) | ||
return | ||
} | ||
|
||
if !reflect.DeepEqual(got, tt.want) { | ||
t.Errorf("ReadFile() got = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
// Assert | ||
if config.GetString("name") != "nitro-server" { | ||
t.Errorf("expected %q to be %q; got %q instead", "name", "nitro-server", config.GetString("name")) | ||
} | ||
// check if the defaults are set | ||
if config.GetInt("cpu") != 2 { | ||
t.Errorf("expected %q to be %q; got %q instead", "cpu", 2, config.GetInt("cpu")) | ||
} | ||
if config.GetString("memory") != "2G" { | ||
t.Errorf("expected %q to be %q; got %q instead", "memory", "2G", config.GetString("memory")) | ||
} | ||
if config.GetString("disk") != "20G" { | ||
t.Errorf("expected %q to be %q; got %q instead", "disk", "20G", config.GetString("disk")) | ||
} | ||
} |
File renamed without changes.
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 @@ | ||
name: nitro-partial |