<commit_before>package httpauth

import (
    "bytes"
    "database/sql"
    "fmt"
    _ "github.com/go-sql-driver/mysql"
    "os"
    "testing"
)

var (
    sb         SqlAuthBackend
    driverName = "mysql"
    driverInfo = "testuser:TestPasswd9@tcp(localhost:3306)/test"
)

func TestSqlInit(t *testing.T) {
    con, err := sql.Open(driverName, driverInfo)
    if err != nil {
        t.Errorf("Couldn't set up test database: %v", err)
        fmt.Printf("Couldn't set up test database: %v\n", err)
        os.Exit(1)
    }
    err = con.Ping()
    if err != nil {
        t.Errorf("Couldn't ping test database: %v", err)
        fmt.Printf("Couldn't ping test database: %v\n", err)
        // t.Errorf("Couldn't ping test database: %v\n", err)
        os.Exit(1)
    }
    con.Exec("drop table goauth")
}

func TestNewSqlAuthBackend(t *testing.T) {
    sb = NewSqlAuthBackend(driverName, driverInfo)
    if sb.driverName != driverName {
        t.Fatal("Driver name.")
    }
    if sb.dataSourceName != driverInfo {
        t.Fatal("Driver info not saved.")
    }
}

func TestSaveUser_sql(t *testing.T) {
    user2 := UserData{"username2", "email2", []byte("<PASSWORD>"), "role2"}
    if err := sb.SaveUser(user2); err != nil {
        t.Fatalf("SaveUser sql error: %v", err)
    }

    user := UserData{"username", "email", []byte("<PASSWORD>"), "role"}
    if err := sb.SaveUser(user); err != nil {
        t.Fatalf("SaveUser sql error: %v", err)
    }
}

func TestNewSqlAuthBackend_existing(t *testing.T) {
    b2 := NewSqlAuthBackend(driverName, driverInfo)
<commit_msg>setting up for testing<commit_after>package httpauth

import (
    "bytes"
    "database/sql"
    "fmt"
    _ "github.com/go-sql-driver/mysql"
    "os"
    "testing"
)

var (
    sb         SqlAuthBackend
    driverName = "mysql"
    driverInfo = "travis@tcp(127.0.0.1:3306)/test"
)

func TestSqlInit(t *testing.T) {
    con, err := sql.Open(driverName, driverInfo)
    if err != nil {
        t.Errorf("Couldn't set up test sql database: %v", err)
        fmt.Printf("Couldn't set up test sql database: %v\n", err)
        os.Exit(1)
    }
    err = con.Ping()
    if err != nil {
        t.Errorf("Couldn't ping test sql database: %v", err)
        fmt.Printf("Couldn't ping test sql database: %v\n", err)
        // t.Errorf("Couldn't ping test database: %v\n", err)
        os.Exit(1)
    }
    con.Exec("drop table goauth")
}

func TestNewSqlAuthBackend(t *testing.T) {
    sb = NewSqlAuthBackend(driverName, driverInfo)
    if sb.driverName != driverName {
        t.Fatal("Driver name.")
    }
    if sb.dataSourceName != driverInfo {
        t.Fatal("Driver info not saved.")
    }
}

func TestSaveUser_sql(t *testing.T) {
    user2 := UserData{"username2", "email2", []byte("<PASSWORD>"), "role2"}
    if err := sb.SaveUser(user2); err != nil {
        t.Fatalf("SaveUser sql error: %v", err)
    }

    user := UserData{"username", "email", []byte("<PASSWORD>"), "role"}
    if err := sb.SaveUser(user); err != nil {
        t.Fatalf("SaveUser sql error: %v", err)
    }
}

func TestNewSqlAuthBackend_existing(t *testing.T) {
    b2 := NewSqlAuthBackend(driverName, driverInfo)

{'fraction_non_alphanumeric': 0.1579778830963665, 'fraction_numerical': 0.009794628751974723, 'mean_word_length': 2.7467455621301777, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, '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': '6674501', 'n_tokens_mistral': 1127, 'n_tokens_neox': 1117, 'n_words': 257}