<commit_before>package db

import (
	"testing"
)

const (
	listname  = "testlist"
	testdata1 = "abc123"
	testdata2 = "<PASSWORD>"
	testdata3 = "ghi789"
)

func TestLocalConnection(t *testing.T) {
	if err := TestConnection(); err != nil {
		t.Errorf(err.Error())
	}
}

func TestList(t *testing.T) {
	//host := New() // locally
	host := NewHost("travis@/main") // for travis-ci
	//host := NewHost("")
	//host := NewHost("/")
	//host := NewHost("/mjaun")
	//host := NewHost("@/mjaun")
	//host := NewHost("go:go@/mjaun") // laptop
	defer host.Close()
	list := NewList(host, listname)
	list.Clear()
	if err := list.Add(testdata1); err != nil {
		t.Errorf("Error, could not add item to list! %s", err.Error())
	}
	items, err := list.GetAll()
	if err != nil {
		t.Errorf("Error when retrieving list! %s", err.Error())
	}
	if len(items) != 1 {
		t.Errorf("Error, wrong list length! %v", len(items))
	}
	if (len(items) > 0) && (items[0] != testdata1) {
		t.Errorf("Error, wrong list contents! %v", items)
	}
	if err := list.Add(testdata2); err != nil {
		t.Errorf("Error, could not add item to list! %s", err.Error())
	}
	if err := list.Add(testdata3); err != nil {
		t.Errorf("Error, could not add item to list! %s", err.Error())
	}
	items, err = list.GetAll()<commit_msg>Different username for db when testing<commit_after>package db

import (
	"testing"
)

const (
	listname  = "testlist"
	testdata1 = "abc123"
	testdata2 = "<PASSWORD>"
	testdata3 = "ghi789"
)

func TestLocalConnection(t *testing.T) {
	if err := TestConnection(); err != nil {
		t.Errorf(err.Error())
	}
}

func TestList(t *testing.T) {
	//host := New() // locally
	host := NewHost("root@/main") // for travis-ci
	//host := NewHost("")
	//host := NewHost("/")
	//host := NewHost("/mjaun")
	//host := NewHost("@/mjaun")
	//host := NewHost("go:go@/mjaun") // laptop
	defer host.Close()
	list := NewList(host, listname)
	list.Clear()
	if err := list.Add(testdata1); err != nil {
		t.Errorf("Error, could not add item to list! %s", err.Error())
	}
	items, err := list.GetAll()
	if err != nil {
		t.Errorf("Error when retrieving list! %s", err.Error())
	}
	if len(items) != 1 {
		t.Errorf("Error, wrong list length! %v", len(items))
	}
	if (len(items) > 0) && (items[0] != testdata1) {
		t.Errorf("Error, wrong list contents! %v", items)
	}
	if err := list.Add(testdata2); err != nil {
		t.Errorf("Error, could not add item to list! %s", err.Error())
	}
	if err := list.Add(testdata3); err != nil {
		t.Errorf("Error, could not add item to list! %s", err.Error())
	}
	items, err = list.GetAll()
{'fraction_non_alphanumeric': 0.20462563700509603, 'fraction_numerical': 0.012544100352802822, 'mean_word_length': 3.656934306569343, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, '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': '5118866', 'n_tokens_mistral': 1012, 'n_tokens_neox': 985, 'n_words': 256}