github.com/google/syzkaller@v0.0.0-20251211124644-a066d2bc4b02/syz-cluster/pkg/db/stats_repo_test.go (about)

     1  // Copyright 2025 syzkaller project authors. All rights reserved.
     2  // Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
     3  
     4  package db
     5  
     6  import (
     7  	"testing"
     8  
     9  	"github.com/stretchr/testify/assert"
    10  )
    11  
    12  func TestStatsSQLs(t *testing.T) {
    13  	// Ideally, there should be some proper tests, but for now let's at least
    14  	// check that the SQL queries themselves have no errors.
    15  	// That already brings a lot of value.
    16  	client, ctx := NewTransientDB(t)
    17  
    18  	checkStats := func() {
    19  		statsRepo := NewStatsRepository(client)
    20  		_, err := statsRepo.ProcessedSeriesPerWeek(ctx)
    21  		assert.NoError(t, err)
    22  		_, err = statsRepo.FindingsPerWeek(ctx)
    23  		assert.NoError(t, err)
    24  		_, err = statsRepo.SessionStatusPerWeek(ctx)
    25  		assert.NoError(t, err)
    26  		_, err = statsRepo.DelayPerWeek(ctx)
    27  		assert.NoError(t, err)
    28  		_, err = statsRepo.ReportsPerWeek(ctx)
    29  		assert.NoError(t, err)
    30  	}
    31  
    32  	dtd := &dummyTestData{t, ctx, client}
    33  	session := dtd.dummySession(dtd.dummySeries())
    34  	checkStats()
    35  	dtd.startSession(session)
    36  	dtd.addSessionTest(session, "test")
    37  	checkStats()
    38  	dtd.addFinding(session, "test", "test")
    39  	checkStats()
    40  	dtd.finishSession(session)
    41  	checkStats()
    42  }