mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2026-01-31 08:11:45 +01:00
Adapt unit test to changed implementation
This commit is contained in:
@@ -7,35 +7,48 @@ package web
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
ccconf "github.com/ClusterCockpit/cc-lib/v2/ccConfig"
|
||||
)
|
||||
|
||||
func TestInit(t *testing.T) {
|
||||
fp := "../../configs/config.json"
|
||||
ccconf.Init(fp)
|
||||
cfg := ccconf.GetPackageConfig("ui")
|
||||
func TestInitDefaults(t *testing.T) {
|
||||
// Test Init with nil config uses defaults
|
||||
err := Init(nil)
|
||||
if err != nil {
|
||||
t.Fatalf("Init failed: %v", err)
|
||||
}
|
||||
|
||||
Init(cfg)
|
||||
|
||||
if UIDefaultsMap["nodeList_usePaging"] == false {
|
||||
t.Errorf("wrong option\ngot: %v \nwant: true", UIDefaultsMap["NodeList_UsePaging"])
|
||||
// Check default values are set
|
||||
if UIDefaultsMap["jobList_usePaging"] != false {
|
||||
t.Errorf("wrong option\ngot: %v \nwant: false", UIDefaultsMap["jobList_usePaging"])
|
||||
}
|
||||
if UIDefaultsMap["nodeList_usePaging"] != false {
|
||||
t.Errorf("wrong option\ngot: %v \nwant: false", UIDefaultsMap["nodeList_usePaging"])
|
||||
}
|
||||
if UIDefaultsMap["jobView_showPolarPlot"] != true {
|
||||
t.Errorf("wrong option\ngot: %v \nwant: true", UIDefaultsMap["jobView_showPolarPlot"])
|
||||
}
|
||||
}
|
||||
|
||||
func TestSimpleDefaults(t *testing.T) {
|
||||
const s = `{
|
||||
"job-list": {
|
||||
"show-footprint": false
|
||||
"show-footprint": true
|
||||
}
|
||||
}`
|
||||
|
||||
Init(json.RawMessage(s))
|
||||
err := Init(json.RawMessage(s))
|
||||
if err != nil {
|
||||
t.Fatalf("Init failed: %v", err)
|
||||
}
|
||||
|
||||
if UIDefaultsMap["jobList_usePaging"] == true {
|
||||
t.Errorf("wrong option\ngot: %v \nwant: false", UIDefaultsMap["NodeList_UsePaging"])
|
||||
// Verify show-footprint was set
|
||||
if UIDefaultsMap["jobList_showFootprint"] != true {
|
||||
t.Errorf("wrong option\ngot: %v \nwant: true", UIDefaultsMap["jobList_showFootprint"])
|
||||
}
|
||||
|
||||
// Verify other defaults remain unchanged
|
||||
if UIDefaultsMap["jobList_usePaging"] != false {
|
||||
t.Errorf("wrong option\ngot: %v \nwant: false", UIDefaultsMap["jobList_usePaging"])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,9 +72,11 @@ func TestOverwrite(t *testing.T) {
|
||||
}
|
||||
}`
|
||||
|
||||
Init(json.RawMessage(s))
|
||||
err := Init(json.RawMessage(s))
|
||||
if err != nil {
|
||||
t.Fatalf("Init failed: %v", err)
|
||||
}
|
||||
|
||||
fmt.Printf("%+v", UIDefaultsMap)
|
||||
v, ok := UIDefaultsMap["metricConfig_jobListMetrics"].([]string)
|
||||
if ok {
|
||||
if v[0] != "flops_sp" {
|
||||
|
||||
Reference in New Issue
Block a user