Skip to content

Commit

Permalink
Fix missing test
Browse files Browse the repository at this point in the history
  • Loading branch information
peterjan committed Apr 7, 2022
1 parent 87e5e23 commit a5eff05
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions database/database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func TestDatabase(t *testing.T) {
name string
test func(t *testing.T)
}{

{
name: "BlockedHashes",
test: testBlockedHashes,
Expand Down Expand Up @@ -109,6 +109,37 @@ func testBlockedHashes(t *testing.T) {
t.Fatal(err)
}
}()

// assert there's no hash that needs to be blocked
toBlock, err := db.HashesToBlock(ctx, time.Time{})
if err != nil {
t.Fatal(err)
}
if len(toBlock) != 0 {
t.Fatalf("expected 0 hashes, instead it was %v", len(toBlock))
}

// insert a regular document
hash := HashBytes([]byte("skylink_1"))
err = db.CreateBlockedSkylink(ctx, &BlockedSkylink{
Skylink: "skylink_1",
Hash: hash,
Reporter: Reporter{},
Tags: []string{"tag_1"},
TimestampAdded: time.Now().UTC(),
})
if err != nil {
t.Fatal(err)
}

// assert there's one hash that needs to be blocked
toBlock, err = db.HashesToBlock(ctx, time.Time{})
if err != nil {
t.Fatal(err)
}
if len(toBlock) != 1 {
t.Fatalf("expected 1 hash, instead it was %v", len(toBlock))
}
}

// testCreateBlockedSkylink tests creating and fetching a blocked skylink from
Expand Down Expand Up @@ -567,7 +598,6 @@ func testMarkInvalid(t *testing.T) {
}
}


// testPing is a unit test for the database's Ping method.
func testPing(t *testing.T) {
// create context
Expand Down

0 comments on commit a5eff05

Please sign in to comment.