-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bootstrap config conversion (#122)
* fix bootstrap config conversion * set defaults for testing
- Loading branch information
1 parent
0799b2f
commit 6616fa0
Showing
2 changed files
with
34 additions
and
8 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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package v1 | ||
|
||
import ( | ||
"testing" | ||
|
||
. "github.com/onsi/gomega" | ||
) | ||
|
||
func TestBootstrapConfigFromMap(t *testing.T) { | ||
g := NewWithT(t) | ||
// Create a new BootstrapConfig with default values | ||
bc := &BootstrapConfig{ | ||
Components: []string{"dns", "network", "storage"}, | ||
ClusterCIDR: "10.1.0.0/16", | ||
} | ||
|
||
// Convert the BootstrapConfig to a map | ||
m, err := bc.ToMap() | ||
g.Expect(err).To(BeNil()) | ||
|
||
// Unmarshal the YAML string from the map into a new BootstrapConfig instance | ||
bcyaml, err := BootstrapConfigFromMap(m) | ||
|
||
// Check for errors | ||
g.Expect(err).To(BeNil()) | ||
// Compare the unmarshaled BootstrapConfig with the original one | ||
g.Expect(bcyaml).To(Equal(bc)) // Note the *bc here to compare values, not pointers | ||
|
||
} |