|
| 1 | +// Copyright The OpenTelemetry Authors |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +// Copyright The OpenTelemetry Authors |
| 16 | +// |
| 17 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 18 | +// you may not use this file except in compliance with the License. |
| 19 | +// You may obtain a copy of the License at |
| 20 | +// |
| 21 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 22 | +// |
| 23 | +// Unless required by applicable law or agreed to in writing, software |
| 24 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 25 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 26 | +// See the License for the specific language governing permissions and |
| 27 | +// limitations under the License. |
| 28 | + |
| 29 | +package configconverter |
| 30 | + |
| 31 | +import ( |
| 32 | + "context" |
| 33 | + "testing" |
| 34 | + |
| 35 | + "github.com/stretchr/testify/assert" |
| 36 | + "github.com/stretchr/testify/require" |
| 37 | + "go.opentelemetry.io/collector/confmap/confmaptest" |
| 38 | +) |
| 39 | + |
| 40 | +func TestNormalizeGcp(t *testing.T) { |
| 41 | + expectedCfgMap, err := confmaptest.LoadConf("testdata/normalize_gcp/upstream_agent_config_post_migration.yaml") |
| 42 | + require.NotNil(t, expectedCfgMap) |
| 43 | + require.NoError(t, err) |
| 44 | + |
| 45 | + cfgMap, err := confmaptest.LoadConf("testdata/normalize_gcp/upstream_agent_config.yaml") |
| 46 | + require.NoError(t, err) |
| 47 | + require.NotNil(t, cfgMap) |
| 48 | + |
| 49 | + err = NormalizeGcp{}.Convert(context.Background(), cfgMap) |
| 50 | + require.NoError(t, err) |
| 51 | + |
| 52 | + assert.Equal(t, expectedCfgMap, cfgMap) |
| 53 | +} |
| 54 | + |
| 55 | +func TestNormalizeGcpMany(t *testing.T) { |
| 56 | + expectedCfgMap, err := confmaptest.LoadConf("testdata/normalize_gcp/upstream_agent_config_post_migration.yaml") |
| 57 | + require.NotNil(t, expectedCfgMap) |
| 58 | + require.NoError(t, err) |
| 59 | + |
| 60 | + cfgMap, err := confmaptest.LoadConf("testdata/normalize_gcp/upstream_agent_config_many.yaml") |
| 61 | + require.NoError(t, err) |
| 62 | + require.NotNil(t, cfgMap) |
| 63 | + |
| 64 | + err = NormalizeGcp{}.Convert(context.Background(), cfgMap) |
| 65 | + require.NoError(t, err) |
| 66 | + |
| 67 | + assert.Equal(t, expectedCfgMap, cfgMap) |
| 68 | +} |
| 69 | + |
| 70 | +func TestNormalizeGcpSame(t *testing.T) { |
| 71 | + expectedCfgMap, err := confmaptest.LoadConf("testdata/normalize_gcp/upstream_agent_config_post_migration.yaml") |
| 72 | + require.NotNil(t, expectedCfgMap) |
| 73 | + require.NoError(t, err) |
| 74 | + |
| 75 | + cfgMap, err := confmaptest.LoadConf("testdata/normalize_gcp/upstream_agent_config_post_migration.yaml") |
| 76 | + require.NoError(t, err) |
| 77 | + require.NotNil(t, cfgMap) |
| 78 | + |
| 79 | + err = NormalizeGcp{}.Convert(context.Background(), cfgMap) |
| 80 | + require.NoError(t, err) |
| 81 | + |
| 82 | + assert.Equal(t, expectedCfgMap, cfgMap) |
| 83 | +} |
0 commit comments