<commit_before>package expr

import (
	"fmt"
	"testing"

	"goa.design/goa/eval"
)

func TestServiceExprValidate(t *testing.T) {
	const (
		identifier = "result"
	)
	var (
		requirements = func(schemes ...*SchemeExpr) []*SecurityExpr {
			if len(schemes) > 0 {
				return []*SecurityExpr{{Schemes: schemes}}
			}
			return nil
		}
		service = func(schemes ...*SchemeExpr) *ServiceExpr {
			return &ServiceExpr{
				Name:         "test",
				Requirements: requirements(schemes...),
			}<commit_msg>Add tests for expe.ServiceExpr.Method() (#1983)<commit_after>package expr

import (
	"fmt"
	"testing"

	"goa.design/goa/eval"
)

func TestServiceExprMethod(t *testing.T) {
	var (
		methodFoo = &MethodExpr{
			Name: "foo",
		}
		methodBar = &MethodExpr{
			Name: "bar",
		}
	)
	cases := map[string]struct {
		name     string
		expected *MethodExpr
	}{
		"exist": {
			name:     "foo",
			expected: methodFoo,
		},
		"not exist": {
			name:     "baz",
			expected: nil,
		},
	}

	for k, tc := range cases {
		s := ServiceExpr{
			Methods: []*MethodExpr{
				methodFoo,
				methodBar,
			},
		}
		if actual := s.Method(tc.name); actual != tc.expected {
			t.Errorf("%s: got %#v, expected %#v", k, actual, tc.expected)
		}
	}
}

func TestServiceExprValidate(t *testing.T) {
	const (
		identifier = "result"
	)
	var (
		requirements = func(schemes ...*SchemeExpr) []*SecurityExpr {
			if len(schemes) > 0 {
				return []*SecurityExpr{{Schemes: schemes}}
			}
			return nil
		}
		service = func(schemes ...*SchemeExpr) *ServiceExpr {
			return &ServiceExpr{
				Name:         "test",
				Requirements: requirements(schemes...),
			}
{'fraction_non_alphanumeric': 0.15782983970406905, 'fraction_numerical': 0.0036991368680641184, 'mean_word_length': 2.997536945812808, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5175856', 'n_tokens_mistral': 683, 'n_tokens_neox': 588, 'n_words': 127}