mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2025-12-16 12:16:16 +01:00
Fix unit tests
This commit is contained in:
@@ -16,31 +16,31 @@ import (
|
|||||||
func TestFind(t *testing.T) {
|
func TestFind(t *testing.T) {
|
||||||
r := setup(t)
|
r := setup(t)
|
||||||
|
|
||||||
jobId, cluster, startTime := int64(398998), "fritz", int64(1675957496)
|
jobID, cluster, startTime := int64(398800), "fritz", int64(1675954712)
|
||||||
job, err := r.Find(&jobId, &cluster, &startTime)
|
job, err := r.Find(&jobID, &cluster, &startTime)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// fmt.Printf("%+v", job)
|
// fmt.Printf("%+v", job)
|
||||||
|
|
||||||
if *job.ID != 5 {
|
if *job.ID != 345 {
|
||||||
t.Errorf("wrong summary for diagnostic 3\ngot: %d \nwant: 1366", job.JobID)
|
t.Errorf("wrong summary for diagnostic \ngot: %d \nwant: 345", job.JobID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFindById(t *testing.T) {
|
func TestFindById(t *testing.T) {
|
||||||
r := setup(t)
|
r := setup(t)
|
||||||
|
|
||||||
job, err := r.FindById(getContext(t), 5)
|
job, err := r.FindById(getContext(t), 338)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// fmt.Printf("%+v", job)
|
// fmt.Printf("%+v", job)
|
||||||
|
|
||||||
if job.JobID != 398998 {
|
if job.JobID != 398793 {
|
||||||
t.Errorf("wrong summary for diagnostic 3\ngot: %d \nwant: 1404396", job.JobID)
|
t.Errorf("wrong summary for diagnostic \ngot: %d \nwant: 1404396", job.JobID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
// All rights reserved. This file is part of cc-backend.
|
// All rights reserved. This file is part of cc-backend.
|
||||||
// Use of this source code is governed by a MIT-style
|
// Use of this source code is governed by a MIT-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package repository
|
package repository
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -28,7 +29,7 @@ func TestJobStats(t *testing.T) {
|
|||||||
stats, err := r.JobsStats(getContext(t), []*model.JobFilter{filter})
|
stats, err := r.JobsStats(getContext(t), []*model.JobFilter{filter})
|
||||||
noErr(t, err)
|
noErr(t, err)
|
||||||
|
|
||||||
if stats[0].TotalJobs != 6 {
|
if stats[0].TotalJobs != 544 {
|
||||||
t.Fatalf("Want 98, Got %d", stats[0].TotalJobs)
|
t.Fatalf("Want 544, Got %d", stats[0].TotalJobs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,15 +79,8 @@ func TestGetUIConfig(t *testing.T) {
|
|||||||
t.Fatal("No config")
|
t.Fatal("No config")
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp, exists := cfg["metricConfig_jobListMetrics"]
|
_, exists := cfg["metricConfig_jobListMetrics:fritz"]
|
||||||
if exists {
|
if !exists {
|
||||||
|
|
||||||
metrics := tmp.([]string)
|
|
||||||
str := metrics[2]
|
|
||||||
if str != "flops_any" {
|
|
||||||
t.Errorf("wrong config\ngot: %s \nwant: flops_any", str)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
t.Fatal("Key metricConfig_jobListMetrics is missing")
|
t.Fatal("Key metricConfig_jobListMetrics is missing")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ func TestRegister(t *testing.T) {
|
|||||||
func TestMatch(t *testing.T) {
|
func TestMatch(t *testing.T) {
|
||||||
r := setup(t)
|
r := setup(t)
|
||||||
|
|
||||||
job, err := r.FindByIdDirect(5)
|
job, err := r.FindByIdDirect(317)
|
||||||
noErr(t, err)
|
noErr(t, err)
|
||||||
|
|
||||||
var tagger AppTagger
|
var tagger AppTagger
|
||||||
@@ -53,7 +53,7 @@ func TestMatch(t *testing.T) {
|
|||||||
|
|
||||||
tagger.Match(job)
|
tagger.Match(job)
|
||||||
|
|
||||||
if !r.HasTag(5, "app", "vasp") {
|
if !r.HasTag(317, "app", "vasp") {
|
||||||
t.Errorf("missing tag vasp")
|
t.Errorf("missing tag vasp")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,14 +18,14 @@ func TestInit(t *testing.T) {
|
|||||||
func TestJobStartCallback(t *testing.T) {
|
func TestJobStartCallback(t *testing.T) {
|
||||||
Init()
|
Init()
|
||||||
r := setup(t)
|
r := setup(t)
|
||||||
job, err := r.FindByIdDirect(2)
|
job, err := r.FindByIdDirect(525)
|
||||||
noErr(t, err)
|
noErr(t, err)
|
||||||
|
|
||||||
jobs := make([]*schema.Job, 0, 1)
|
jobs := make([]*schema.Job, 0, 1)
|
||||||
jobs = append(jobs, job)
|
jobs = append(jobs, job)
|
||||||
|
|
||||||
repository.CallJobStartHooks(jobs)
|
repository.CallJobStartHooks(jobs)
|
||||||
if !r.HasTag(2, "app", "python") {
|
if !r.HasTag(525, "app", "python") {
|
||||||
t.Errorf("missing tag python")
|
t.Errorf("missing tag python")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user