<commit_before>package main

import (
	"testing"

	"github.com/stretchr/testify/assert"
)

func TestNewDatabase(t *testing.T) {
	_, err := NewDatabase(":memory:")
	if err != nil {
		t.Error("%s", err.Error())
	}
}

func TestGet(t *testing.T) {
	db, err := NewDatabase(":memory:")
	if err != nil {
		t.Error(err.Error())
	}

	err = db.Import("../fixture/zanxp.sql")
	if err != nil {
		t.Fatal(err.Error())
	}

	row, err := db.Get("alexmax")
	if err != nil {
		t.Fatal(err.Error())
	}
	assert.Equal(t, "alexmax", row.Name, "Should return proper row name")
	assert.Equal(t, StringInt32(359450), row.Experience, "Should return proper row experience")
	assert.Equal(t, StringFloat64(1459903084.82901), row.Timestamp, "Should return proper row timestamp")

	row, err = db.Get("anonymous")
	if err != nil {
		t.Fatal(err.Error())
	}
	assert.Nil(t, row, "Should be nil")
}

func TestGetSince(t *testing.T) {
	db, err := NewDatabase(":memory:")
	if err != nil {
		t.Error(err.Error())
	}

	err = db.Import("../fixture/zanxp.sql")
	if err != nil {
		t.Fatal(err.Error())
	}

	rows, err := db.GetSince(1459903084.82901)
	if err != nil {
		t.Fatal(err.Error())
	}
	assert.Equal(t, 2, len(rows), "Should return two values")
}<commit_msg>Use assert.NoError() instead of explicit nil error checks.<commit_after>package main

import (
	"testing"

	"github.com/stretchr/testify/assert"
)

func TestNewDatabase(t *testing.T) {
	_, err := NewDatabase(":memory:")
	assert.NoError(t, err)
}

func TestGet(t *testing.T) {
	db, err := NewDatabase(":memory:")
	if !assert.NoError(t, err) {
		t.FailNow()
	}

	err = db.Import("../fixture/zanxp.sql")
	if !assert.NoError(t, err) {
		t.FailNow()
	}

	row, err := db.Get("alexmax")
	if assert.NoError(t, err) {
		assert.Equal(t, "alexmax", row.Name, "Should return proper row name")
		assert.Equal(t, StringInt32(359450), row.Experience, "Should return proper row experience")
		assert.Equal(t, StringFloat64(1459903084.82901), row.Timestamp, "Should return proper row timestamp")
	}

	row, err = db.Get("anonymous")
	if assert.NoError(t, err) {
		assert.Nil(t, row, "Should be nil")
	}
}

func TestGetSince(t *testing.T) {
	db, err := NewDatabase(":memory:")
	if !assert.NoError(t, err) {
		t.FailNow()
	}

	err = db.Import("../fixture/zanxp.sql")
	if !assert.NoError(t, err) {
		t.FailNow()
	}

	rows, err := db.GetSince(1459903084.82901)
	if assert.NoError(t, err) {
		assert.Equal(t, 2, len(rows), "Should return two values")
	}

	rows, err = db.GetSince(2000000000)
	if assert.NoError(t, err) {
		assert.Equal(t, 0, len(rows), "Should return no values")
	}
}
{'fraction_non_alphanumeric': 0.18452611218568665, 'fraction_numerical': 0.03597678916827853, 'mean_word_length': 4.080550098231827, 'pattern_counts': {'":': 6, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1425722', 'n_tokens_mistral': 1114, 'n_tokens_neox': 1012, 'n_words': 222}