Skip to content

Commit

Permalink
Update provider_test.go
Browse files Browse the repository at this point in the history
  • Loading branch information
jagan2221 authored Dec 4, 2024
1 parent bc34997 commit 11e7d5a
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion pkg/configprovider/opampprovider/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,48 @@ func TestRemotelyManagedFlowDisabled(t *testing.T) {
"processor": "someprocessor",
"extensions::opamp::remote_configuration_directory": "../globprovider/testdata/mergefunc",
"extensions::opamp::endpoint": "wss://example.com/v1/opamp",
"extensions::opamp::new_configmergeflow_disabled": false,
"extensions::opamp::new_configmergeflow_disabled": true,
})
want := exp.ToStringMap()
if diff := cmp.Diff(want, got); diff != "" {
t.Errorf("Retrieve() mismatch (-want +got):\n%s", diff)
}
}

func TestRemotelyManagedFlowEnabled(t *testing.T) {
p := NewWithSettings(confmap.ProviderSettings{})
defer func() {
if err := p.Shutdown(context.Background()); err != nil {
t.Error(err)
}
}()

configPath := "opamp:" + absolutePath(t, filepath.Join("testdata", "configMergeEnabled.yaml"))
t.Logf("loading opamp config file: %s", configPath)

ret, err := p.Retrieve(context.Background(), configPath, nil)
if err != nil {
t.Fatal(err)
}
conf, err := ret.AsConf()
if err != nil {
t.Fatal(err)
}
got := conf.ToStringMap()
exp := confmap.NewFromStringMap(map[string]any{
"extensions::sumologic::childKey": "value",
"extensions::sumologic::collector_fields::zone": "eu",
"processor": "someprocessor",
"extensions::opamp::remote_configuration_directory": "../globprovider/testdata/mergefunc",
"extensions::opamp::endpoint": "wss://example.com/v1/opamp",
})
want := exp.ToStringMap()
if diff := cmp.Diff(want, got); diff != "" {
t.Errorf("Retrieve() mismatch (-want +got):\n%s", diff)
}
}


func absolutePath(t *testing.T, relativePath string) string {
t.Helper()
pth, err := filepath.Abs(relativePath)
Expand Down

0 comments on commit 11e7d5a

Please sign in to comment.