mirror of https://github.com/pulumi/pulumi.git
36 lines
1.3 KiB
Go
36 lines
1.3 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 (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
//nolint:paralleltest // mutates environment variables
|
|
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
|
|
t.Setenv("PULUMI_API", "https://api-test3.pulumi.com/")
|
|
assert.Equal(t, "https://api-test3.pulumi.com/", ValueOrDefaultURL(""))
|
|
})
|
|
}
|