Files
substrate/cmd/ateapi/internal/controlapi/worker_test.go
T
Luiz Oliveira eda290e788 Consolidate the worker controlapi handlers into one file (#916)
Since we only have ListWorkers so far, this is just a file rename. The
rest of the handlers should be added to this file, instead of new
handler-specific files, as per #891

- [x] Tests pass
- [x] Appropriate changes to documentation are included in the PR
2026-08-13 12:52:37 -04:00

48 lines
1.3 KiB
Go

// Copyright 2026 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package controlapi
import (
"testing"
"github.com/agent-substrate/substrate/pkg/proto/ateapipb"
"k8s.io/apimachinery/pkg/util/validation/field"
)
func TestValidateListWorkersRequest(t *testing.T) {
tests := []struct {
name string
req *ateapipb.ListWorkersRequest
want field.ErrorList
}{{
"valid, no page_size",
&ateapipb.ListWorkersRequest{},
nil,
}, {
"valid, positive page_size",
&ateapipb.ListWorkersRequest{PageSize: 10},
nil,
}, {
"negative page_size",
&ateapipb.ListWorkersRequest{PageSize: -1},
field.ErrorList{field.Invalid(field.NewPath("page_size"), int32(-1), "")},
}}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
assertValidateErr(t, validateListWorkersRequest(tt.req), tt.want)
})
}
}