Skip to content

Commit

Permalink
feat(test): add skeleton structs
Browse files Browse the repository at this point in the history
Define multiple structs to implement the tests.

Signed-off-by: Alexander Hansen <[email protected]>
  • Loading branch information
pointbazaar committed Sep 17, 2024
1 parent 1dd4fd8 commit d6d0de8
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"golangci",
"goreleaser",
"libc",
"wagoid"
"wagoid",
"ipmitool"
],
"ignoreWords": [],
"version": "0.2"
Expand Down
19 changes: 19 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,29 @@ package main

import (
"fmt"

"github.com/9elements/bmc-test-go/pkg/test"
)

const bmcTestGoVersion = "v0.0.0"

func printResult(result test.Result) {

fmt.Printf("TEST [%s]:", result.Name);

if (result.Error != nil) {
fmt.Printf(" Error: %v", result.Error);
} else {
fmt.Printf(" PASS");
}

fmt.Println();
}

func main() {
fmt.Println(bmcTestGoVersion)

var result = test.Result{Name:"nop test", Error:nil};

printResult(result);
}
38 changes: 38 additions & 0 deletions pkg/test/test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Package test implements the common structs used for defining
// testcases.
package test

// Config struct is used to pass arbitrary information into the tests
// such as IP address, expected FRU content, expected sensors
type Config struct {

Host string;
Username string;
Password string;

// ... to be extended
}

// Result struct is used for returning test results from running a test
type Result struct {

// what was tested
Name string

// != nil in case something went wrong,
// this should contain a descriptive string for the logs.
// e.g. "while running command X, expected A but output was B'
Error error
}

// Test struct is used to define a test which can return one or more results
type Test struct {

// e.g. "IPMI Sensor"
Name string

// e.g. "Testing the 'ipmitool sensor' output
Description string

Function func(tc Config) []Result
}

0 comments on commit d6d0de8

Please sign in to comment.