Skip to main content
Glama

protolint-mcp

by yoheimuta
serviceNamesEndWithRule_test.go2.16 kB
package rules_test import ( "reflect" "testing" "github.com/yoheimuta/go-protoparser/v4/parser" "github.com/yoheimuta/go-protoparser/v4/parser/meta" "github.com/yoheimuta/protolint/internal/addon/rules" "github.com/yoheimuta/protolint/linter/report" "github.com/yoheimuta/protolint/linter/rule" ) func TestValidServiceNamesEndWithRule_Apply(t *testing.T) { validTestCase := struct { name string inputProto *parser.Proto wantFailures []report.Failure }{ name: "no failures for proto with valid service names", inputProto: &parser.Proto{ ProtoBody: []parser.Visitee{ &parser.Service{ ServiceName: "SomeServiceService", }, &parser.Service{ ServiceName: "AnotherService", }, }, }, } t.Run(validTestCase.name, func(t *testing.T) { rule := rules.NewServiceNamesEndWithRule(rule.SeverityError, "Service") _, err := rule.Apply(validTestCase.inputProto) if err != nil { t.Errorf("got err %v, but want nil", err) return } }) } func TestInvalidServiceNamesEndWithRule_Apply(t *testing.T) { invalidTestCase := struct { name string inputProto *parser.Proto wantFailures []report.Failure }{ name: "failures for proto with invalid service names", inputProto: &parser.Proto{ ProtoBody: []parser.Visitee{ &parser.Service{ ServiceName: "SomeThing", }, &parser.Service{ ServiceName: "AnotherThing", }, }, }, wantFailures: []report.Failure{ report.Failuref(meta.Position{}, "SERVICE_NAMES_END_WITH", string(rule.SeverityError), `Service name "SomeThing" must end with Service`), report.Failuref(meta.Position{}, "SERVICE_NAMES_END_WITH", string(rule.SeverityError), `Service name "AnotherThing" must end with Service`), }, } t.Run(invalidTestCase.name, func(t *testing.T) { rule := rules.NewServiceNamesEndWithRule(rule.SeverityError, "Service") got, err := rule.Apply(invalidTestCase.inputProto) if err != nil { t.Errorf("got err %v, but want nil", err) return } if !reflect.DeepEqual(got, invalidTestCase.wantFailures) { t.Errorf("got %v, but want %v", got, invalidTestCase.wantFailures) } }) }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/yoheimuta/protolint'

If you have feedback or need assistance with the MCP directory API, please join our Discord server