-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
178 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package internal_test | ||
|
||
import ( | ||
"io/ioutil" | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/reddec/ingress-dashboard/internal" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestLoadDefinitions(t *testing.T) { | ||
tempDir, err := ioutil.TempDir("", "") | ||
require.NoError(t, err) | ||
defer os.RemoveAll(tempDir) | ||
|
||
err = ioutil.WriteFile(filepath.Join(tempDir, "demo.yaml"), []byte(` | ||
--- | ||
name: Some site | ||
namespace: external links # used in 'from' | ||
urls: | ||
- https://example.com | ||
--- | ||
name: Google | ||
namespace: external links | ||
logo_url: https://www.google.ru/favicon.ico | ||
description: | | ||
Well-known search engine | ||
urls: | ||
- https://google.com | ||
- http://example.com | ||
`), 0755) | ||
require.NoError(t, err) | ||
|
||
list, err := internal.LoadDefinitions(tempDir) | ||
require.NoError(t, err) | ||
require.Len(t, list, 2) | ||
|
||
require.Equal(t, internal.Ingress{ | ||
Name: "Some site", | ||
Namespace: "external links", | ||
Refs: []internal.Ref{ | ||
{URL: "https://example.com", Static: true}, | ||
}, | ||
}, list[0]) | ||
|
||
require.Equal(t, internal.Ingress{ | ||
Name: "Google", | ||
Namespace: "external links", | ||
Description: "Well-known search engine\n", | ||
LogoURL: "https://www.google.ru/favicon.ico", | ||
Refs: []internal.Ref{ | ||
{URL: "https://google.com", Static: true}, | ||
{URL: "http://example.com", Static: true}, | ||
}, | ||
}, list[1]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters