Skip to content

Various minor improvements to unit tests for package index projects #190

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions internal/project/projectdata/packageindex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,60 +59,60 @@ func TestInitializeForPackageIndex(t *testing.T) {
packageIndexPackagesAssertion: assert.NotNil,
packageIndexPackagesDataAssertion: []PackageIndexData{
{
ID: "myboard1",
ID: "foopackager1",
JSONPointer: "/packages/0",
},
{
ID: "myboard2",
ID: "foopackager2",
JSONPointer: "/packages/1",
},
},
packageIndexPlatformsAssertion: assert.NotNil,
packageIndexPlatformsDataAssertion: []PackageIndexData{
{
ID: "myboard1:[email protected]",
ID: "foopackager1:[email protected]",
JSONPointer: "/packages/0/platforms/0",
},
{
ID: "myboard1:[email protected]",
ID: "foopackager1:[email protected]",
JSONPointer: "/packages/0/platforms/1",
},
{
ID: "myboard2:[email protected]",
ID: "foopackager2:[email protected]",
JSONPointer: "/packages/1/platforms/0",
},
{
ID: "myboard2:[email protected]",
ID: "foopackager2:[email protected]",
JSONPointer: "/packages/1/platforms/1",
},
},
packageIndexToolsAssertion: assert.NotNil,
packageIndexToolsDataAssertion: []PackageIndexData{
{
ID: "myboard2:[email protected]",
ID: "foopackager2:[email protected]",
JSONPointer: "/packages/1/tools/0",
},
{
ID: "myboard2:[email protected]",
ID: "foopackager2:[email protected]",
JSONPointer: "/packages/1/tools/1",
},
},
packageIndexSystemsAssertion: assert.NotNil,
packageIndexSystemsDataAssertion: []PackageIndexData{
{
ID: "myboard2:[email protected] - i386-apple-darwin11",
ID: "foopackager2:[email protected] - i386-apple-darwin11",
JSONPointer: "/packages/1/tools/0/systems/0",
},
{
ID: "myboard2:[email protected] - x86_64-linux-gnu",
ID: "foopackager2:[email protected] - x86_64-linux-gnu",
JSONPointer: "/packages/1/tools/0/systems/1",
},
{
ID: "myboard2:[email protected] - arm-linux-gnueabihf",
ID: "foopackager2:[email protected] - arm-linux-gnueabihf",
JSONPointer: "/packages/1/tools/1/systems/0",
},
{
ID: "myboard2:[email protected] - i686-mingw32",
ID: "foopackager2:[email protected] - i686-mingw32",
JSONPointer: "/packages/1/tools/1/systems/1",
},
},
Expand Down Expand Up @@ -159,32 +159,32 @@ func TestInitializeForPackageIndex(t *testing.T) {
testTable.packageIndexPackagesAssertion(t, PackageIndexPackages(), testTable.testName)
if PackageIndexPackages() != nil {
for index, packageIndexPackage := range PackageIndexPackages() {
assert.Equal(t, packageIndexPackage.ID, testTable.packageIndexPackagesDataAssertion[index].ID)
assert.Equal(t, packageIndexPackage.JSONPointer, testTable.packageIndexPackagesDataAssertion[index].JSONPointer)
assert.Equal(t, testTable.packageIndexPackagesDataAssertion[index].ID, packageIndexPackage.ID, testTable.testName)
assert.Equal(t, testTable.packageIndexPackagesDataAssertion[index].JSONPointer, packageIndexPackage.JSONPointer, testTable.testName)
}
}

testTable.packageIndexPlatformsAssertion(t, PackageIndexPlatforms(), testTable.testName)
if PackageIndexPlatforms() != nil {
for index, packageIndexPlatform := range PackageIndexPlatforms() {
assert.Equal(t, packageIndexPlatform.ID, testTable.packageIndexPlatformsDataAssertion[index].ID)
assert.Equal(t, packageIndexPlatform.JSONPointer, testTable.packageIndexPlatformsDataAssertion[index].JSONPointer)
assert.Equal(t, testTable.packageIndexPlatformsDataAssertion[index].ID, packageIndexPlatform.ID, testTable.testName)
assert.Equal(t, testTable.packageIndexPlatformsDataAssertion[index].JSONPointer, packageIndexPlatform.JSONPointer, testTable.testName)
}
}

testTable.packageIndexToolsAssertion(t, PackageIndexTools(), testTable.testName)
if PackageIndexTools() != nil {
for index, packageIndexTool := range PackageIndexTools() {
assert.Equal(t, packageIndexTool.ID, testTable.packageIndexToolsDataAssertion[index].ID)
assert.Equal(t, packageIndexTool.JSONPointer, testTable.packageIndexToolsDataAssertion[index].JSONPointer)
assert.Equal(t, testTable.packageIndexToolsDataAssertion[index].ID, packageIndexTool.ID, testTable.testName)
assert.Equal(t, testTable.packageIndexToolsDataAssertion[index].JSONPointer, packageIndexTool.JSONPointer, testTable.testName)
}
}

testTable.packageIndexSystemsAssertion(t, PackageIndexSystems(), testTable.testName)
if PackageIndexSystems() != nil {
for index, packageIndexSystem := range PackageIndexSystems() {
assert.Equal(t, packageIndexSystem.ID, testTable.packageIndexSystemsDataAssertion[index].ID)
assert.Equal(t, packageIndexSystem.JSONPointer, testTable.packageIndexSystemsDataAssertion[index].JSONPointer)
assert.Equal(t, testTable.packageIndexSystemsDataAssertion[index].ID, packageIndexSystem.ID, testTable.testName)
assert.Equal(t, testTable.packageIndexSystemsDataAssertion[index].JSONPointer, packageIndexSystem.JSONPointer, testTable.testName)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"packages": [
{
"name": "myboard1",
"name": "foopackager1",
"maintainer": "Jane Developer",
"websiteURL": "https://github.com/janedeveloper/myboard",
"email": "[email protected]",
Expand Down Expand Up @@ -65,7 +65,7 @@
"tools": []
},
{
"name": "myboard2",
"name": "foopackager2",
"maintainer": "Jane Developer",
"websiteURL": "https://github.com/janedeveloper/myboard",
"email": "[email protected]",
Expand Down
12 changes: 6 additions & 6 deletions internal/rule/rulefunction/packageindex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ func TestPackageIndexFormat(t *testing.T) {
func TestPackageIndexPackagesWebsiteURLDeadLink(t *testing.T) {
testTables := []packageIndexRuleFunctionTestTable{
{"Invalid JSON", "invalid-JSON", ruleresult.NotRun, ""},
{"Dead URLs", "packages-websiteurl-dead", ruleresult.Fail, "^myboard1, myboard2$"},
{"Invalid URL", "packages-websiteurl-invalid", ruleresult.Fail, "^myboard$"},
{"Dead URLs", "packages-websiteurl-dead", ruleresult.Fail, "^foopackager1, foopackager2$"},
{"Invalid URL", "packages-websiteurl-invalid", ruleresult.Fail, "^foopackager$"},
{"Valid URL", "valid-package-index", ruleresult.Pass, ""},
}

Expand All @@ -125,7 +125,7 @@ func TestPackageIndexPackagesWebsiteURLDeadLink(t *testing.T) {
func TestPackageIndexPackagesHelpOnlineDeadLink(t *testing.T) {
testTables := []packageIndexRuleFunctionTestTable{
{"Invalid JSON", "invalid-JSON", ruleresult.NotRun, ""},
{"Dead URLs", "packages-help-online-dead", ruleresult.Fail, "^myboard1, myboard2$"},
{"Dead URLs", "packages-help-online-dead", ruleresult.Fail, "^foopackager1, foopackager2$"},
{"Valid URL", "valid-package-index", ruleresult.Pass, ""},
}

Expand All @@ -135,7 +135,7 @@ func TestPackageIndexPackagesHelpOnlineDeadLink(t *testing.T) {
func TestPackageIndexPackagesPlatformsHelpOnlineDeadLink(t *testing.T) {
testTables := []packageIndexRuleFunctionTestTable{
{"Invalid JSON", "invalid-JSON", ruleresult.NotRun, ""},
{"Dead URLs", "packages-platforms-help-online-dead", ruleresult.Fail, "^myboard:avr@1\\.0\\.0, myboard:samd@1\\.0\\.0$"},
{"Dead URLs", "packages-platforms-help-online-dead", ruleresult.Fail, "^foopackager:avr@1\\.0\\.0, foopackager:samd@1\\.0\\.0$"},
{"Valid URL", "valid-package-index", ruleresult.Pass, ""},
}

Expand All @@ -145,7 +145,7 @@ func TestPackageIndexPackagesPlatformsHelpOnlineDeadLink(t *testing.T) {
func TestPackageIndexPackagesPlatformsURLDeadLink(t *testing.T) {
testTables := []packageIndexRuleFunctionTestTable{
{"Invalid JSON", "invalid-JSON", ruleresult.NotRun, ""},
{"Dead URLs", "packages-platforms-url-dead", ruleresult.Fail, "^myboard:avr@1\\.0\\.0, myboard:samd@1\\.0\\.0$"},
{"Dead URLs", "packages-platforms-url-dead", ruleresult.Fail, "^foopackager:avr@1\\.0\\.0, foopackager:samd@1\\.0\\.0$"},
{"Valid URL", "valid-package-index", ruleresult.Pass, ""},
}

Expand All @@ -155,7 +155,7 @@ func TestPackageIndexPackagesPlatformsURLDeadLink(t *testing.T) {
func TestPackageIndexPackagesToolsSystemsURLDeadLink(t *testing.T) {
testTables := []packageIndexRuleFunctionTestTable{
{"Invalid JSON", "invalid-JSON", ruleresult.NotRun, ""},
{"Dead URLs", "packages-tools-systems-url-dead", ruleresult.Fail, "^myboard:CMSIS@4\\.0\\.0-atmel - arm-linux-gnueabihf, myboard:CMSIS@4\\.0\\.0-atmel - i686-mingw32$"},
{"Dead URLs", "packages-tools-systems-url-dead", ruleresult.Fail, "^foopackager:CMSIS@4\\.0\\.0-atmel - arm-linux-gnueabihf, foopackager:CMSIS@4\\.0\\.0-atmel - i686-mingw32$"},
{"Valid URL", "valid-package-index", ruleresult.Pass, ""},
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"packages": [
{
"name": "myboard1",
"name": "foopackager1",
"maintainer": "Jane Developer",
"websiteURL": "http://example.com",
"email": "[email protected]",
Expand All @@ -12,7 +12,7 @@
"tools": []
},
{
"name": "myboard2",
"name": "foopackager2",
"maintainer": "Jane Developer",
"websiteURL": "http://example.com",
"email": "[email protected]",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"packages": [
{
"name": "myboard",
"name": "foopackager",
"maintainer": "Jane Developer",
"websiteURL": "http://example.com",
"email": "[email protected]",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"packages": [
{
"name": "myboard",
"name": "foopackager",
"maintainer": "Jane Developer",
"websiteURL": "http://example.com",
"email": "[email protected]",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"packages": [
{
"name": "myboard",
"name": "foopackager",
"maintainer": "Jane Developer",
"websiteURL": "http://httpstat.us/404",
"email": "[email protected]",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"packages": [
{
"name": "myboard1",
"name": "foopackager1",
"maintainer": "Jane Developer",
"websiteURL": "http://httpstat.us/403",
"email": "[email protected]",
Expand All @@ -12,7 +12,7 @@
"tools": []
},
{
"name": "myboard2",
"name": "foopackager2",
"maintainer": "Jane Developer",
"websiteURL": "http://httpstat.us/404",
"email": "[email protected]",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"packages": [
{
"name": "myboard",
"name": "foopackager",
"maintainer": "Jane Developer",
"websiteURL": "invalid",
"email": "[email protected]",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"packages": [
{
"name": "myboard",
"name": "foopackager",
"maintainer": "Jane Developer",
"websiteURL": "http://example.com",
"email": "[email protected]",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"packages": [
{
"name": "myboard",
"name": "foopackager",
"maintainer": "Jane Developer",
"websiteURL": "http://example.com",
"email": "[email protected]",
Expand Down