analysistest

package
v0.3.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 12, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TestData = func(t testing.TB) string {
	t.Helper()
	testdata, err := filepath.Abs("testdata")
	if err != nil {
		t.Fatal(err)
	}
	return testdata
}

TestData returns absolute path of testdata. If TestData cannot get the path, the test will be failed.

Functions

This section is empty.

Types

type Result

type Result = checker.AnalyzerResult

Result is a result of an analyzer.

func Run

func Run(t testing.TB, testdata string, a *gqlanalysis.Analyzer, dirs ...string) []*Result

Run runs tests for an analyzer. The given directries which are in testdata, have "schema" and "query" directory. Run applies the analyzer for schemas and queries which are hold on these directories. Run checks whether expected diagnostics is reported and unexpected ones are not by the analyzer. An expected diagnostic can be written with a comment in a .graphql file. The comment begin "want" and a Go's regular expression folows it. For example, if the analyzer must report "NG" as a diagnostic, it can test with such as following.

query Q {
    a { # want "NG"
         name
    }
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL