From 2139807d586c9ab1ee8f579fdc52b4fbe0acc7cf Mon Sep 17 00:00:00 2001 From: teowa <104055472+teowa@users.noreply.github.com> Date: Wed, 11 Sep 2024 04:22:15 +0000 Subject: [PATCH] fix error message level --- coverage/coverage.go | 7 +++---- coverage/coverage_test.go | 11 ++++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/coverage/coverage.go b/coverage/coverage.go index d2b8299..270b3c0 100644 --- a/coverage/coverage.go +++ b/coverage/coverage.go @@ -131,7 +131,7 @@ func (m *Model) MarkCovered(root interface{}) { if m.Enum != nil { strValue := fmt.Sprintf("%v", value) if _, ok := (*m.Enum)[strValue]; !ok { - logrus.Errorf("unexpected enum %s in %s", value, m.Identifier) + logrus.Warningf("unexpected enum %s in %s", value, m.Identifier) } (*m.Enum)[strValue] = true @@ -192,9 +192,8 @@ func (m *Model) MarkCovered(root interface{}) { if isMatchProperty { for k, v := range value { if m.Properties == nil { - if !m.HasAdditionalProperties { - logrus.Errorf("unexpected key %s in %s", k, m.Identifier) - } + // some objects has no properties defined + // https://github.com/Azure/azure-rest-api-specs/blob/3519c80fe510a268f6e59a29ccac8a53fdec15b6/specification/monitor/resource-manager/Microsoft.Insights/stable/2023-03-11/dataCollectionRules_API.json#L724 continue } if _, ok := (*m.Properties)[k]; !ok { diff --git a/coverage/coverage_test.go b/coverage/coverage_test.go index 8eda804..c5cd972 100644 --- a/coverage/coverage_test.go +++ b/coverage/coverage_test.go @@ -291,7 +291,9 @@ func TestCoverage_DataMigrationServiceTasks(t *testing.T) { "properties": { "taskType": "ConnectToSource.MySql", "input": { - "targetPlatform": "string" + "sourceConnectionInfo": { + "serverName": "mySqlService" + } } } }`, @@ -873,8 +875,7 @@ func TestCoverage_DataCollectionRule(t *testing.T) { "extensions": [ { "streams": [ - "Microsoft-WindowsEvent", - "Microsoft-ServiceMap" + "Microsoft-WindowsEvent" ], "inputDataSources": [ "test-datasource-wineventlog" @@ -961,7 +962,7 @@ func TestCoverage_AKS(t *testing.T) { "archv2": "" }, "sku": { - "name": "Basic", + "name": "Base", "tier": "Free" }, "properties": { @@ -1505,7 +1506,7 @@ func testCoverage(t *testing.T, tc testCase) (*coverage.Model, error) { request := map[string]interface{}{} err = json.Unmarshal([]byte(rq), &request) if err != nil { - t.Error(err) + t.Errorf("error unmarshal request json: %v", err) } model.MarkCovered(request)