コード例 #1
0
func TestBoltDBDoesNotExist(t *testing.T) {
	deleteBeforeTest(t)
	db, err := New(TEST_DB_PATH)
	if err != nil {
		t.Fatalf("Could not open test db: %s", err)
	}
	defer testutils.CloseInTest(t, db)
	if _, _, err := db.Load("deadbeef"); err == nil {
		t.Errorf("Should have seen error, but did not")
	}
}
コード例 #2
0
func TestBoltDBStoreAndRetrieve(t *testing.T) {
	deleteBeforeTest(t)
	db, err := New(TEST_DB_PATH)
	if err != nil {
		t.Fatalf("Could not open test db: %s", err)
	}
	defer testutils.CloseInTest(t, db)
	if err := db.Store(expectedBinaryReport1, expectedBinaryFuzzNames, "deadbeef"); err != nil {
		t.Errorf("Could not store to test db:%s ", err)
	}
	report, names, err := db.Load("deadbeef")
	if err != nil {
		t.Fatalf("Error while loading: %s", err)
	}
	if !reflect.DeepEqual(expectedBinaryReport1, *report) {
		t.Errorf("Expected: %#v\n, but was: %#v", expectedBinaryReport1, *report)
	}
	if !reflect.DeepEqual(expectedBinaryFuzzNames, names) {
		t.Errorf("Expected: %#v\n, but was: %#v", expectedBinaryFuzzNames, names)
	}
}