mirror of
https://github.com/opentffoundation/opentf.git
synced 2026-02-28 23:01:32 -05:00
* Remove `make updatedeps` from Travis build. We'll follow up with more specific plans around dependency updating in subsequent PRs. * Update all `make` targets to set `GO15VENDOREXPERIMENT=1` and to filter out `/vendor/` from `./...` where appropriate. * Temporarily remove `vet` from the `make test` target until we can figure out how to get it to not vet `vendor/`. (Initial experimentation failed to yield the proper incantation.) Everything is pinned to current master, with the exception of: * Azure/azure-sdk-for-go which is pinned before the breaking change today * aws/aws-sdk-go which is pinned to the most recent tag The documentation still needs to be updated, which we can do in a follow up PR. The goal here is to unblock release.
86 lines
2.6 KiB
Go
86 lines
2.6 KiB
Go
package gophercloud
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
|
|
th "github.com/rackspace/gophercloud/testhelper"
|
|
)
|
|
|
|
func TestWaitFor(t *testing.T) {
|
|
err := WaitFor(5, func() (bool, error) {
|
|
return true, nil
|
|
})
|
|
th.CheckNoErr(t, err)
|
|
}
|
|
|
|
func TestNormalizeURL(t *testing.T) {
|
|
urls := []string{
|
|
"NoSlashAtEnd",
|
|
"SlashAtEnd/",
|
|
}
|
|
expected := []string{
|
|
"NoSlashAtEnd/",
|
|
"SlashAtEnd/",
|
|
}
|
|
for i := 0; i < len(expected); i++ {
|
|
th.CheckEquals(t, expected[i], NormalizeURL(urls[i]))
|
|
}
|
|
|
|
}
|
|
|
|
func TestNormalizePathURL(t *testing.T) {
|
|
baseDir, _ := os.Getwd()
|
|
|
|
rawPath := "template.yaml"
|
|
basePath, _ := filepath.Abs(".")
|
|
result, _ := NormalizePathURL(basePath, rawPath)
|
|
expected := strings.Join([]string{"file:/", filepath.ToSlash(baseDir), "template.yaml"}, "/")
|
|
th.CheckEquals(t, expected, result)
|
|
|
|
rawPath = "http://www.google.com"
|
|
basePath, _ = filepath.Abs(".")
|
|
result, _ = NormalizePathURL(basePath, rawPath)
|
|
expected = "http://www.google.com"
|
|
th.CheckEquals(t, expected, result)
|
|
|
|
rawPath = "very/nested/file.yaml"
|
|
basePath, _ = filepath.Abs(".")
|
|
result, _ = NormalizePathURL(basePath, rawPath)
|
|
expected = strings.Join([]string{"file:/", filepath.ToSlash(baseDir), "very/nested/file.yaml"}, "/")
|
|
th.CheckEquals(t, expected, result)
|
|
|
|
rawPath = "very/nested/file.yaml"
|
|
basePath = "http://www.google.com"
|
|
result, _ = NormalizePathURL(basePath, rawPath)
|
|
expected = "http://www.google.com/very/nested/file.yaml"
|
|
th.CheckEquals(t, expected, result)
|
|
|
|
rawPath = "very/nested/file.yaml/"
|
|
basePath = "http://www.google.com/"
|
|
result, _ = NormalizePathURL(basePath, rawPath)
|
|
expected = "http://www.google.com/very/nested/file.yaml"
|
|
th.CheckEquals(t, expected, result)
|
|
|
|
rawPath = "very/nested/file.yaml"
|
|
basePath = "http://www.google.com/even/more"
|
|
result, _ = NormalizePathURL(basePath, rawPath)
|
|
expected = "http://www.google.com/even/more/very/nested/file.yaml"
|
|
th.CheckEquals(t, expected, result)
|
|
|
|
rawPath = "very/nested/file.yaml"
|
|
basePath = strings.Join([]string{"file:/", filepath.ToSlash(baseDir), "only/file/even/more"}, "/")
|
|
result, _ = NormalizePathURL(basePath, rawPath)
|
|
expected = strings.Join([]string{"file:/", filepath.ToSlash(baseDir), "only/file/even/more/very/nested/file.yaml"}, "/")
|
|
th.CheckEquals(t, expected, result)
|
|
|
|
rawPath = "very/nested/file.yaml/"
|
|
basePath = strings.Join([]string{"file:/", filepath.ToSlash(baseDir), "only/file/even/more"}, "/")
|
|
result, _ = NormalizePathURL(basePath, rawPath)
|
|
expected = strings.Join([]string{"file:/", filepath.ToSlash(baseDir), "only/file/even/more/very/nested/file.yaml"}, "/")
|
|
th.CheckEquals(t, expected, result)
|
|
|
|
}
|