mirror of
https://github.com/agent-substrate/substrate.git
synced 2026-11-10 10:13:50 +08:00
functional_test.go was also split into one file per resource, to match what we're doing for the RPC handlers too. See #891 I also needed to make some changes to move the tests to a separate package: * `NewAteletDialer` now takes `options`, and `WithDialCredentials` lets a test build its own transport credentials. The fake atelet is reached over insecure transport. Didn't change existing callers. This is the only non-test change. * Moved a few unit tests that are actually functional tests to the respective file under functionaltest/ Fixes #891 - [x] Tests pass - [x] Appropriate changes to documentation are included in the PR
49 lines
1.4 KiB
Go
49 lines
1.4 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 (
|
|
"fmt"
|
|
"testing"
|
|
|
|
"github.com/agent-substrate/substrate/pkg/proto/ateapipb"
|
|
"google.golang.org/protobuf/testing/protocmp"
|
|
"k8s.io/apimachinery/pkg/util/validation/field"
|
|
)
|
|
|
|
// Helpers shared by the unit tests in this package.
|
|
const (
|
|
testAtespace = "test-atespace"
|
|
testActorID = "id1"
|
|
)
|
|
|
|
var (
|
|
ignoreUID = protocmp.IgnoreFields(&ateapipb.ResourceMetadata{}, "uid")
|
|
ignoreTimestamps = protocmp.IgnoreFields(&ateapipb.ResourceMetadata{}, "create_time", "update_time")
|
|
)
|
|
|
|
func selectorLabelsOfSize(n int) map[string]string {
|
|
labels := make(map[string]string, n)
|
|
for i := 0; i < n; i++ {
|
|
labels[fmt.Sprintf("k%d", i)] = "v"
|
|
}
|
|
return labels
|
|
}
|
|
|
|
func assertValidateErr(t *testing.T, got field.ErrorList, want field.ErrorList) {
|
|
t.Helper()
|
|
field.ErrorMatcher{}.ByType().ByField().ByValue().Test(t, want, got)
|
|
}
|