-
Notifications
You must be signed in to change notification settings - Fork 245
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into rmuller/fix-nested-types
- Loading branch information
Showing
48 changed files
with
2,989 additions
and
2,673 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
244 changes: 119 additions & 125 deletions
244
gh-pages/content/specification/6-compliance-report.md
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package tests | ||
|
||
import ( | ||
"encoding/json" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/suite" | ||
"io/ioutil" | ||
"strings" | ||
) | ||
|
||
type ComplianceSuite struct { | ||
suite.Suite | ||
_report map[string]map[string]string | ||
} | ||
|
||
func (suite *ComplianceSuite) SetupSuite() { | ||
suite._report = map[string]map[string]string{} | ||
} | ||
|
||
func (suite *ComplianceSuite) TearDownSuite() { | ||
report, err := json.MarshalIndent(suite._report, "", " ") | ||
|
||
if err != nil { | ||
suite.FailNowf("Failed marshalling _report: %s", err.Error()) | ||
} | ||
err = ioutil.WriteFile("./compliance-report.json", report, 0644) | ||
if err != nil { | ||
suite.FailNowf("Failed writing _report: %s", err.Error()) | ||
} | ||
} | ||
|
||
func (suite *ComplianceSuite) Assert() *assert.Assertions { | ||
return assert.New(suite.T()) | ||
} | ||
|
||
func (suite* ComplianceSuite) reportForTest() map[string]string { | ||
fullName := suite.T().Name() | ||
testName := strings.Split(fullName, "/")[1] | ||
name := strings.Replace(testName, "Test", "", 1) | ||
|
||
if val, ok := suite._report[name]; ok { | ||
return val | ||
} | ||
|
||
val := map[string]string{} | ||
suite._report[name] = val | ||
return val | ||
} | ||
|
||
func (suite *ComplianceSuite) BeforeTest(suiteName, testName string) { | ||
suite.reportForTest()["status"] = "success" | ||
} | ||
|
||
func (suite *ComplianceSuite) skipWithStatus(status string, reason string, url string) { | ||
t := suite.T() | ||
|
||
report := suite.reportForTest() | ||
|
||
report["status"] = status | ||
if reason != "" { | ||
report["reason"] = reason | ||
} | ||
|
||
if url != "" { | ||
report["url"] = url | ||
} | ||
|
||
t.Skipf("%s: %s", status, reason) | ||
} | ||
|
||
// FailTest will report this test as failing with the URL of the github issue that | ||
// reports the bug or missing feature | ||
func (suite *ComplianceSuite) FailTest(reason string, issueUrl string) { | ||
suite.skipWithStatus("failure", reason, issueUrl) | ||
} | ||
|
||
// NotApplicableTest will report this compliance test as N/A for this language | ||
func (suite *ComplianceSuite) NotApplicableTest(reason string) { | ||
suite.skipWithStatus("n/a", reason, "") | ||
} |
Oops, something went wrong.