@@ -9,10 +9,8 @@ import (
99 "crypto/rsa"
1010 "crypto/x509"
1111 "crypto/x509/pkix"
12- "database/sql"
1312 "encoding/asn1"
1413 "encoding/pem"
15- "errors"
1614 "log"
1715 "math/big"
1816 mrand "math/rand/v2"
@@ -389,25 +387,20 @@ func TestGetAndProcessCerts(t *testing.T) {
389387// asked for the actual rows.
390388type mismatchedCountDB struct {}
391389
392- // `getCerts` calls `SelectInt` first to determine how many rows there are
393- // matching the `getCertsCountQuery` criteria. For this mock we return
394- // a non-zero number
395- func (db mismatchedCountDB ) SelectNullInt (_ context.Context , _ string , _ ... any ) (sql.NullInt64 , error ) {
396- return sql.NullInt64 {
397- Int64 : 99999 ,
398- Valid : true ,
399- },
400- nil
401- }
402-
403390// `getCerts` then calls `Select` to retrieve the Certificate rows. We pull
404391// a dastardly switch-a-roo here and return an empty set
405392func (db mismatchedCountDB ) Select (_ context.Context , output any , _ string , _ ... any ) ([]any , error ) {
406393 return nil , nil
407394}
408395
409- func (db mismatchedCountDB ) SelectOne (_ context.Context , _ any , _ string , _ ... any ) error {
410- return errors .New ("unimplemented" )
396+ // `getCerts` calls `SelectOne` first to determine how many rows there are
397+ // matching the `getCertsCountQuery` criteria. For this mock we return
398+ // a non-zero number
399+ func (db mismatchedCountDB ) SelectOne (_ context.Context , holder any , _ string , _ ... any ) error {
400+ h := holder .(* * int64 )
401+ var nines int64 = 99999
402+ * h = & nines
403+ return nil
411404}
412405
413406/*
@@ -445,11 +438,12 @@ type emptyDB struct {
445438 certDB
446439}
447440
448- // SelectNullInt is a method that returns a false sql.NullInt64 struct to
449- // mock a null DB response
450- func (db emptyDB ) SelectNullInt (_ context.Context , _ string , _ ... any ) (sql.NullInt64 , error ) {
451- return sql.NullInt64 {Valid : false },
452- nil
441+ // SelectOne is a method that stores `nil` in the passed int64 holder.
442+ // It's used to mock a null DB response (i.e. MIN across now rows).
443+ func (db emptyDB ) SelectOne (_ context.Context , holder any , _ string , _ ... any ) error {
444+ h := holder .(* * int64 )
445+ * h = nil
446+ return nil
453447}
454448
455449// TestGetCertsNullResults tests that a null response from the database will
@@ -473,16 +467,22 @@ type lateDB struct {
473467 selectedACert bool
474468}
475469
476- // SelectNullInt is a method that returns a false sql.NullInt64 struct to
477- // mock a null DB response
478- func (db * lateDB ) SelectNullInt (_ context.Context , _ string , args ... any ) (sql.NullInt64 , error ) {
470+ // SelectOne is a method that stores `nil` in the passed int64 holder.
471+ // It's used to mock a null DB response (i.e. MIN across now rows).
472+ func (db lateDB ) SelectOne (_ context.Context , holder any , _ string , args ... any ) error {
473+ h := holder .(* * int64 )
474+
479475 args2 := args [0 ].(map [string ]any )
480476 begin := args2 ["begin" ].(time.Time )
481477 end := args2 ["end" ].(time.Time )
482478 if begin .Compare (db .issuedTime ) < 0 && end .Compare (db .issuedTime ) > 0 {
483- return sql.NullInt64 {Int64 : 23 , Valid : true }, nil
479+ var twentythree int64 = 23
480+ * h = & twentythree
481+ return nil
484482 }
485- return sql.NullInt64 {Valid : false }, nil
483+
484+ * h = nil
485+ return nil
486486}
487487
488488func (db * lateDB ) Select (_ context.Context , output any , _ string , args ... any ) ([]any , error ) {
@@ -492,10 +492,6 @@ func (db *lateDB) Select(_ context.Context, output any, _ string, args ...any) (
492492 return nil , nil
493493}
494494
495- func (db * lateDB ) SelectOne (_ context.Context , _ any , _ string , _ ... any ) error {
496- return nil
497- }
498-
499495// TestGetCertsLate checks for correct behavior when certificates exist only late in the provided window.
500496func TestGetCertsLate (t * testing.T ) {
501497 clk := clock .NewFake ()
0 commit comments