Information that will be queried from the OS will be saved in a sturct. This struct will be gradually added methods to get the OS parameters.
@@ -1,5 +1,9 @@
package gupta
+import (
+ "fmt"
+)
+
func Hello() string {
return "Hello, world"
}
@@ -10,3 +14,13 @@ func Run(load, cpu, memory bool, partition, networkInterface string) (cpuLoad, c
memoryUsage = 70.0
return cpuLoad, cpuUsage, memoryUsage
+type GuptaReport struct {
+ cpuLoad float64
+ cpuUsage float64
+ memoryUsage float64
+}
+func (g *GuptaReport) GetCPULoad() string {
+ return fmt.Sprintf("%.2f", g.cpuLoad)
@@ -29,3 +29,20 @@ func TestRunGupta(t *testing.T) {
// having a data structure it would be possible to format
// it to json ...
+func TestGuptaHasReport(t *testing.T) {
+ // test we can get some report struct from gupta
+ report := GuptaReport{
+ cpuLoad: 0.2,
+ cpuUsage: 0.2,
+ memoryUsage: 70.0,
+ }
+ got := report.GetCPULoad()
+ want := "0.20"
+ if got != want {
+ t.Errorf("got %v want %v", got, want)