<commit_before>package query_test

import (
	"testing"

	"github.com/lucapette/deloominator/pkg/query"
)

var variables = query.Variables{
	"{timestamp}": "2017-10-13T23:59:59Z",
}

func TestEval(t *testing.T) {
	type args struct {
		query string
	}
	tests := []struct {
		name string
		args args
		want string
	}{
		{
			"no variables",
			args{
				"select * from answers",
			},
			"select * from answers",
		},
		{
			"{timestamp}",
			args{
				"select * from answers where created_at < {timestamp}",
			},
			`select * from answers where created_at < '2017-10-13T23:59:59Z'`,
		},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			evaler := query.NewEvaler(variables)
			got, err := evaler.Eval(tt.args.query)
			if err != nil {
				t.Errorf("could not eval: %v", err)
			}

			if got != tt.want {
				t.Errorf("Eval() = %v, want %v", got, tt.want)
			}
		})
	}
}<commit_msg>Add more tests for evaler<commit_after>package query_test

import (
	"testing"

	"github.com/lucapette/deloominator/pkg/query"
)

var variables = query.Variables{
	"{timestamp}": "2017-10-13T23:59:59Z",
	"{today}":     "2017-10-15",
	"{yesterday}": "2015-04-15",
}

func TestEval(t *testing.T) {
	tests := []struct {
		name  string
		query string
		want  string
	}{
		{
			"no variables",
			"select * from answers",
			"select * from answers",
		},
		{
			"{timestamp}",
			"select * from answers where created_at < {timestamp}",
			`select * from answers where created_at < '2017-10-13T23:59:59Z'`,
		},
		{
			"{today}",
			"select * from answers where created_at < {today}",
			`select * from answers where created_at < '2017-10-15'`,
		},
		{
			"{yesterday}",
			"select * from answers where created_at < {yesterday}",
			`select * from answers where created_at < '2015-04-15'`,
		},
	}
	for _, test := range tests {
		t.Run(test.name, func(t *testing.T) {
			evaler := query.NewEvaler(variables)
			got, err := evaler.Eval(test.query)
			if err != nil {
				t.Errorf("could not eval: %v", err)
			}

			if got != test.want {
				t.Errorf("Eval() = %v, want %v", got, test.want)
			}
		})
	}
}
{'fraction_non_alphanumeric': 0.17269267364414842, 'fraction_numerical': 0.04186489058039962, 'mean_word_length': 3.036468330134357, 'pattern_counts': {'":': 4, '<': 11, '<?xml version=': 0, '>': 3, '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': '6310600', 'n_tokens_mistral': 966, 'n_tokens_neox': 800, 'n_words': 183}