Skip to content

Commit

Permalink
fix error message level
Browse files Browse the repository at this point in the history
  • Loading branch information
teowa committed Sep 11, 2024
1 parent 8a2d91d commit 2139807
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
7 changes: 3 additions & 4 deletions coverage/coverage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
11 changes: 6 additions & 5 deletions coverage/coverage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,9 @@ func TestCoverage_DataMigrationServiceTasks(t *testing.T) {
"properties": {
"taskType": "ConnectToSource.MySql",
"input": {
"targetPlatform": "string"
"sourceConnectionInfo": {
"serverName": "mySqlService"
}
}
}
}`,
Expand Down Expand Up @@ -873,8 +875,7 @@ func TestCoverage_DataCollectionRule(t *testing.T) {
"extensions": [
{
"streams": [
"Microsoft-WindowsEvent",
"Microsoft-ServiceMap"
"Microsoft-WindowsEvent"
],
"inputDataSources": [
"test-datasource-wineventlog"
Expand Down Expand Up @@ -961,7 +962,7 @@ func TestCoverage_AKS(t *testing.T) {
"archv2": ""
},
"sku": {
"name": "Basic",
"name": "Base",
"tier": "Free"
},
"properties": {
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 2139807

Please sign in to comment.