Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
unit-test: refine func TestGetCPUDetails
Browse files Browse the repository at this point in the history
refine struct testData in func TestGetCPUDetails to remove redundant
/unused struct field expectedVendor and expectedModel

Fixes: #2000

Signed-off-by: Penny Zheng <[email protected]>
  • Loading branch information
Pennyzct committed Feb 14, 2019
1 parent 1b967a4 commit 0185d45
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions cli/kata-check_arm64_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,19 +129,17 @@ func TestKvmIsUsable(t *testing.T) {
func TestGetCPUDetails(t *testing.T) {
type testData struct {
contents string
expectedVendor string
expectedModel string
expectedNormalizeVendor string
expectedNormalizeModel string
expectError bool
}

const validVendorName = "0x41"
const validNormalizeVendorName = "ARM Limited"
validVendorName := "0x41"
validNormalizeVendorName := "ARM Limited"
validVendor := fmt.Sprintf(`%s : %s`, archCPUVendorField, validVendorName)

const validModelName = "8"
const validNormalizeModelName = "v8"
validModelName := "8"
validNormalizeModelName := "v8"
validModel := fmt.Sprintf(`%s : %s`, archCPUModelField, validModelName)

validContents := fmt.Sprintf(`
Expand All @@ -152,12 +150,12 @@ foo : bar
`, validVendor, validModel)

data := []testData{
{"", "", "", "", "", true},
{"invalid", "", "", "", "", true},
{archCPUVendorField, "", "", "", "", true},
{validVendor, "", "", "", "", true},
{validModel, "", "", "", "", true},
{validContents, validVendorName, validModelName, validNormalizeVendorName, validNormalizeModelName, false},
{"", "", "", true},
{"invalid", "", "", true},
{archCPUVendorField, "", "", true},
{validVendor, "", "", true},
{validModel, "", "", true},
{validContents, validNormalizeVendorName, validNormalizeModelName, false},
}

tmpdir, err := ioutil.TempDir("", "")
Expand Down

0 comments on commit 0185d45

Please sign in to comment.