github.com/web-platform-tests/wpt.fyi@v0.0.0-20240530210107-70cf978996f1/api/query/cache/index/results_test.go (about) 1 //go:build small 2 // +build small 3 4 // Copyright 2018 The WPT Dashboard Project. All rights reserved. 5 // Use of this source code is governed by a BSD-style license that can be 6 // found in the LICENSE file. 7 8 package index 9 10 import ( 11 "testing" 12 13 "github.com/stretchr/testify/assert" 14 "github.com/web-platform-tests/wpt.fyi/shared" 15 ) 16 17 func TestForRun_fail(t *testing.T) { 18 rs := NewResults() 19 rrs := rs.ForRun(RunID(0)) 20 assert.Nil(t, rrs) 21 } 22 23 func TestAdd_fail(t *testing.T) { 24 rs := NewResults() 25 rrs1 := NewRunResults() 26 rrs2 := NewRunResults() 27 err := rs.Add(RunID(0), rrs1) 28 assert.Nil(t, err) 29 err = rs.Add(RunID(0), rrs2) 30 assert.NotNil(t, err) 31 } 32 33 func TestAddForRunGetResult(t *testing.T) { 34 rs := NewResults() 35 rrs := NewRunResults() 36 37 ru := RunID(0) 38 re := ResultID(shared.TestStatusOK) 39 te := TestID{} 40 41 rrs.Add(re, te) 42 err := rs.Add(ru, rrs) 43 assert.Nil(t, err) 44 rrs = rs.ForRun(ru) 45 assert.NotNil(t, rrs) 46 assert.Equal(t, re, rrs.GetResult(te)) 47 assert.Equal(t, ResultID(shared.TestStatusUnknown), rrs.GetResult(TestID{1, 1})) 48 }