cc-backend/internal/repository/stats_test.go

38 lines
765 B
Go
Raw Normal View History

2023-06-07 11:58:58 +02:00
// Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
// All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package repository
import (
"fmt"
"testing"
"github.com/ClusterCockpit/cc-backend/internal/graph/model"
2023-06-07 11:58:58 +02:00
)
func TestBuildJobStatsQuery(t *testing.T) {
r := setup(t)
2023-06-09 11:29:07 +02:00
q := r.buildStatsQuery(nil, "USER")
2023-06-07 11:58:58 +02:00
sql, _, err := q.ToSql()
noErr(t, err)
fmt.Printf("SQL: %s\n", sql)
}
func TestJobStats(t *testing.T) {
r := setup(t)
filter := &model.JobFilter{}
var err error
var stats []*model.JobsStatistics
stats, err = r.testJobsStats([]*model.JobFilter{filter})
noErr(t, err)
if stats[0].TotalJobs != 98 {
t.Fatalf("Want 98, Got %d", stats[0].TotalJobs)
}
}