github.com/iasthc/atlas/cmd/atlas@v0.0.0-20230523071841-73246df3f88d/x/x_test.go (about) 1 // Copyright 2021-present The Atlas Authors. All rights reserved. 2 // This source code is licensed under the Apache 2.0 license found 3 // in the LICENSE file in the root directory of this source tree. 4 5 package x_test 6 7 import ( 8 "context" 9 "testing" 10 _ "unsafe" 11 12 "github.com/iasthc/atlas/cmd/atlas/x" 13 "github.com/iasthc/atlas/schemahcl" 14 "github.com/iasthc/atlas/sql/migrate" 15 "github.com/iasthc/atlas/sql/sqlcheck" 16 "github.com/iasthc/atlas/sql/sqlclient" 17 _ "github.com/iasthc/atlas/sql/sqlite" 18 _ "github.com/iasthc/atlas/sql/sqlite/sqlitecheck" 19 20 _ "github.com/mattn/go-sqlite3" 21 "github.com/stretchr/testify/require" 22 ) 23 24 func TestLintLatest(t *testing.T) { 25 ctx := context.Background() 26 dev, err := sqlclient.Open(ctx, "sqlite://ci?mode=memory&cache=shared&_fk=1") 27 require.NoError(t, err) 28 dir := &migrate.MemDir{} 29 require.NoError(t, dir.WriteFile("1.sql", []byte(`CREATE TABLE users (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL);`))) 30 az, err := sqlcheck.AnalyzerFor(dev.Name, &schemahcl.Resource{}) 31 require.NoError(t, err) 32 report, err := lintLatest(ctx, dev, dir, 1, az) 33 require.NoError(t, err) 34 require.NotNil(t, report) 35 } 36 37 //go:linkname lintLatest github.com/iasthc/atlas/cmd/atlas/x.lintLatest 38 func lintLatest(context.Context, *sqlclient.Client, migrate.Dir, int, []sqlcheck.Analyzer) (report *x.SummaryReport, err error)