blob: c0f3982b159aba69f1094cf03247a22d2e11916b [file] [edit]
// 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 rsproxy
import (
"testing"
_ "github.com/bazelbuild/rsclient/internal/pkg/testsetup"
)
// TestBuildPartialInvocation verifies that the initial partial invocation metadata
// is correctly populated, specifically ensuring the ProjectId is the short ID.
func TestBuildPartialInvocation(t *testing.T) {
c := &CLIConfig{
ProxyConfig: ProxyConfig{
ResultStoreEgressOptions: ResultStoreEgressOptions{
RSInstanceName: "projects/my-project/instances/default",
},
},
ProjectId: "my-fuchsia-project",
}
lookupUser := func() string { return "test-user" }
lookupHostname := func() string { return "test-host" }
getWorkingDir := func() string { return "/test/dir" }
inv := c.BuildPartialInvocation("1.2.3", lookupUser, lookupHostname, getWorkingDir)
if inv.InvocationAttributes.ProjectId != "my-project" {
t.Errorf("ProjectId = %q, want %q", inv.InvocationAttributes.ProjectId, "my-project")
}
if inv.InvocationAttributes.Labels[0] != "my-fuchsia-project" {
t.Errorf("Label = %q, want %q", inv.InvocationAttributes.Labels[0], "my-fuchsia-project")
}
if inv.InvocationAttributes.Users[0] != "test-user" {
t.Errorf("User = %q, want %q", inv.InvocationAttributes.Users[0], "test-user")
}
}