pulumi/pkg/backend/httpstate/backend_test.go
Ian Wahbe 272c4643b2
Update error handling (#8406)
This is the result of a change applied via `go-rewrap-errors`.
2021-11-12 18:37:17 -08:00

37 lines
1.2 KiB
Go

// Copyright 2016-2021, Pulumi Corporation.
//
// 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 httpstate
import (
"os"
"testing"
"github.com/stretchr/testify/assert"
)
func TestValueOrDefaultURL(t *testing.T) {
t.Run("TestValueOrDefault", func(t *testing.T) {
// Validate trailing slash gets cut
assert.Equal(t, "https://api-test1.pulumi.com", ValueOrDefaultURL("https://api-test1.pulumi.com/"))
// Validate no-op case
assert.Equal(t, "https://api-test2.pulumi.com", ValueOrDefaultURL("https://api-test2.pulumi.com"))
// Validate trailing slash in pre-set env var is unchanged
os.Setenv("PULUMI_API", "https://api-test3.pulumi.com/")
assert.Equal(t, "https://api-test3.pulumi.com/", ValueOrDefaultURL(""))
os.Unsetenv("PULUMI_API")
})
}