MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / TestCreateLinter

Function TestCreateLinter

cmd/gosqlx/cmd/lint_test.go:927–972  ·  view source on GitHub ↗

TestCreateLinter tests linter creation with rules

(t *testing.T)

Source from the content-addressed store, hash-verified

925
926// TestCreateLinter tests linter creation with rules
927func TestCreateLinter(t *testing.T) {
928 tests := []struct {
929 name string
930 maxLength int
931 expectedRules int
932 }{
933 {
934 name: "Default max-length",
935 maxLength: 100,
936 expectedRules: 10, // L001, L002, L003, L004, L005, L006, L007, L008, L009, L010
937 },
938 {
939 name: "Custom max-length",
940 maxLength: 120,
941 expectedRules: 10,
942 },
943 }
944
945 for _, tt := range tests {
946 t.Run(tt.name, func(t *testing.T) {
947 // Set global flag
948 lintMaxLength = tt.maxLength
949
950 // Create linter
951 linter := createLinter()
952
953 // Verify rule count
954 rules := linter.Rules()
955 if len(rules) != tt.expectedRules {
956 t.Errorf("Expected %d rules, got %d", tt.expectedRules, len(rules))
957 }
958
959 // Verify rule IDs include all expected rules
960 expectedIDs := []string{"L001", "L002", "L003", "L004", "L005", "L010", "L006", "L008", "L009", "L007"}
961 for i, rule := range rules {
962 if i < len(expectedIDs) && rule.ID() != expectedIDs[i] {
963 t.Errorf("Expected rule ID %s at position %d, got %s", expectedIDs[i], i, rule.ID())
964 }
965 }
966
967 // Verify L005 has correct max length
968 // The actual max-length value is tested in TestCreateLinter_MaxLengthPassedToRule
969 t.Logf("Created linter with max-length: %d", tt.maxLength)
970 })
971 }
972}
973
974// TestCreateLinter_MaxLengthPassedToRule verifies max-length is correctly configured
975func TestCreateLinter_MaxLengthPassedToRule(t *testing.T) {

Callers

nothing calls this directly

Calls 5

createLinterFunction · 0.85
RunMethod · 0.80
ErrorfMethod · 0.65
IDMethod · 0.65
RulesMethod · 0.45

Tested by

no test coverage detected