-
Notifications
You must be signed in to change notification settings - Fork 222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(ui): stop using /meta/config endpoint #3684
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package config | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestStorageConfigInfo(t *testing.T) { | ||
tests := []struct { | ||
config StorageConfig | ||
expected map[string]string | ||
}{ | ||
{StorageConfig{Type: DatabaseStorageType}, nil}, | ||
{StorageConfig{Type: GitStorageType, Git: &StorageGitConfig{Repository: "repo1", Ref: "v1.0.0"}}, map[string]string{ | ||
"ref": "v1.0.0", "repository": "repo1", | ||
}}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(string(tt.config.Type), func(t *testing.T) { | ||
assert.Equal(t, tt.expected, tt.config.Info()) | ||
}) | ||
} | ||
} |
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,44 @@ | ||
package info | ||
|
||
import ( | ||
"net/http" | ||
"net/http/httptest" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"go.flipt.io/flipt/internal/config" | ||
"go.flipt.io/flipt/internal/release" | ||
) | ||
|
||
func TestNew(t *testing.T) { | ||
f := New( | ||
WithOS("linux", "amd64"), | ||
WithBuild("commit", "date", "goVersion", "version", true), | ||
WithLatestRelease(release.Info{LatestVersion: "latestVersion", LatestVersionURL: "latestVersionURL", UpdateAvailable: true}), | ||
WithConfig(config.Default()), | ||
) | ||
|
||
assert.Equal(t, "commit", f.Commit) | ||
assert.Equal(t, "date", f.BuildDate) | ||
assert.Equal(t, "goVersion", f.GoVersion) | ||
assert.Equal(t, "version", f.Version) | ||
assert.True(t, f.IsRelease) | ||
assert.Equal(t, "latestVersion", f.LatestVersion) | ||
assert.Equal(t, "latestVersionURL", f.LatestVersionURL) | ||
assert.True(t, f.UpdateAvailable) | ||
assert.Equal(t, "linux", f.OS) | ||
assert.Equal(t, "amd64", f.Arch) | ||
assert.False(t, f.Authentication.Required) | ||
assert.False(t, f.Analytics.Enabled) | ||
assert.Equal(t, config.DatabaseStorageType, f.Storage.Type) | ||
} | ||
|
||
func TestHttpHandler(t *testing.T) { | ||
f := New() | ||
f.Storage.Type = config.DatabaseStorageType | ||
r := httptest.NewRequest("GET", "/info", nil) | ||
w := httptest.NewRecorder() | ||
f.ServeHTTP(w, r) | ||
assert.Equal(t, http.StatusOK, w.Code) | ||
assert.Equal(t, `{"updateAvailable":false,"isRelease":false,"authentication":{"required":false},"storage":{"type":"database"}}`, w.Body.String()) | ||
} |
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
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have an opportunity to refactor this info API endpoint now I think?
maybe we should make the response it a bit more structured, something like:
this would be an API response breaking change, but since the API is not documented for this endpoint maybe its ok?
wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@markphelps I’ve updated the new fields to match the desired format. However, I'm not ready to update old fields in this PR, as it would introduce too many changes at once.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds good to me