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 bdda71b
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
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);
}
34 changes: 34 additions & 0 deletions pkg/test/test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package test

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

Host string;
Username string;
Password string;

// ... to be extended
}

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
}

type Test struct {

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

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

Function func(tc TestConfig) []Result
}

0 comments on commit bdda71b

Please sign in to comment.