package engine

import "testing"

func TestStandardTableSchemaLogStats(t *testing.T) {
	schema, ok := StandardTableSchema("log_stats")
	if !ok {
		t.Fatal("log_stats schema not found")
	}
	if !schema.IsView {
		t.Fatal("log_stats should be marked as a view")
	}

	wantColumns := []string{"hour", "project", "level", "file", "line", "count", "msg_digest", "sample", "component"}
	if len(schema.Columns) != len(wantColumns) {
		t.Fatalf("got %d columns, want %d", len(schema.Columns), len(wantColumns))
	}
	for i, want := range wantColumns {
		if schema.Columns[i].Name != want {
			t.Fatalf("column[%d] = %q, want %q", i, schema.Columns[i].Name, want)
		}
	}

	wantPartitions := []string{"date", "org", "cluster"}
	if len(schema.Partitions) != len(wantPartitions) {
		t.Fatalf("got %d partitions, want %d", len(schema.Partitions), len(wantPartitions))
	}
	for i, want := range wantPartitions {
		if schema.Partitions[i].Name != want {
			t.Fatalf("partition[%d] = %q, want %q", i, schema.Partitions[i].Name, want)
		}
	}
}
