<commit_before><commit_msg>add a test<commit_after>package influxdb

import (
	"testing"
)

func TestClient(t *testing.T) {
	client, err := NewClient(&ClientConfig{})
	if err != nil {
		t.Error(err)
	}

	if err := client.CreateClusterAdmin("admin", "password"); err != nil {
		t.Error(err)
	}

	admins, err := client.GetClusterAdminList()
	if err != nil {
		t.Error(err)
	}

	if len(admins) != 2 {
		t.Error("more than two admins returned")
	}

	if err := client.CreateDatabase("foobar"); err != nil {
		t.Error(err)
	}

	dbs, err := client.GetDatabaseList()
	if err != nil {
		t.Error(err)
	}

	if len(dbs) != 1 && dbs[0]["foobar"] == nil {
		t.Errorf("List of databases don't match")
	}

	if err := client.CreateDatabaseUser("foobar", "dbuser", "pass"); err != nil {
		t.Error(err)
	}

	if err := client.AlterDatabasePrivilege("foobar", "dbuser", true); err != nil {
		t.Error(err)
	}

	users, err := client.GetDatabaseUserList("foobar")
	if err != nil {
		t.Error(err)
	}

	if len(users) != 1 {
		t.Error("more than one user returned")
	}

	client, err = NewClient(&ClientConfig{
		Username: "dbuser",
		Password: "<PASSWORD>",
		Database: "foobar",
	})

	if err != nil {
		t.Error(err)
	}

	series := &Series{
		Name:    "ts9",
		Columns: []string{"value"},
		Points: [][]interface{}{
			[]interface{}{1.0},
		},
	}
	if err := client.WriteSeries([]*Series{series}); err != nil {
		t.Error(err)
	}

	result, err := client.Query("select * from ts9")
	if err != nil {
		t.Error(err)
	}

	if len(result) != 1 {
		t.Error("more than one time series returned")
	}

	if len(result[0].Points) != 1 {
		t.Error("Larger time series returned")
	}

	if result[0].Points[0][2].(float64) != 1 {
		t.Fail()
	}
}
{'fraction_non_alphanumeric': 0.19294117647058823, 'fraction_numerical': 0.01, 'mean_word_length': 3.597297297297297, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '4070811', 'n_tokens_mistral': 713, 'n_tokens_neox': 650, 'n_words': 149}