Separate engine loading from inspection state
This commit is contained in:
@@ -38,7 +38,7 @@ func TestParallelLoadsShareRulesButNotMutableValues(t *testing.T) {
|
||||
}
|
||||
|
||||
const count = 32
|
||||
results := make([]*Result[independentConfig], count)
|
||||
results := make([]*testResult[independentConfig], count)
|
||||
errorsByIndex := make([]error, count)
|
||||
var group sync.WaitGroup
|
||||
for index := range count {
|
||||
@@ -73,6 +73,29 @@ func TestParallelLoadsShareRulesButNotMutableValues(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadedConfigurationIsSeparateFromInspection(t *testing.T) {
|
||||
type configuration struct {
|
||||
Value string `yaml:"value"`
|
||||
}
|
||||
|
||||
loaded, err := Load[configuration](Bytes("config.yml", []byte("value: original\n")), testSecretBinding())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if loaded.Inspection == nil {
|
||||
t.Fatal("inspection is nil")
|
||||
}
|
||||
|
||||
loaded.Config.Value = "mutated"
|
||||
var effective bytes.Buffer
|
||||
if err := loaded.Inspection.WriteEffective(&effective); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if effective.String() != "value: original\n" {
|
||||
t.Fatalf("inspection changed with configuration: %q", effective.String())
|
||||
}
|
||||
}
|
||||
|
||||
func TestConcurrentLoadsOfCopiedReaderSourceHaveOneClaim(t *testing.T) {
|
||||
source := Reader("shared", strings.NewReader("value: one\n"))
|
||||
copied := source
|
||||
|
||||
Reference in New Issue
Block a user