-
Notifications
You must be signed in to change notification settings - Fork 397
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
15 changed files
with
1,299 additions
and
19 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,88 @@ | ||
package grafana | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestPluginsList(t *testing.T) { | ||
result := true | ||
result = result && MockPluginList.HasSomeVersionOf(&Mockplugina100) | ||
result = result && MockPluginList.HasSomeVersionOf(&Mockplugina101) | ||
result = result && MockPluginList.HasSomeVersionOf(&Mockpluginb100) | ||
result = result && MockPluginList.HasSomeVersionOf(&Mockplugina102) | ||
|
||
if !result { | ||
t.Errorf("Error in `HasSomeVersionOf`") | ||
} | ||
|
||
result = result && MockPluginList.HasExactVersionOf(&Mockplugina100) | ||
result = result && MockPluginList.HasExactVersionOf(&Mockplugina101) | ||
result = result && MockPluginList.HasExactVersionOf(&Mockpluginb100) | ||
result = result && (MockPluginList.HasExactVersionOf(&Mockplugina102) == false) | ||
result = result && (MockPluginList.HasExactVersionOf(&Mockpluginc100) == false) | ||
|
||
if !result { | ||
t.Errorf("Error in `HasExactVersionOf`") | ||
} | ||
|
||
result, err := MockPluginList.HasNewerVersionOf(&Mockplugina100) | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
|
||
if !result { | ||
t.Errorf("Error in `HasNewerVersionOf`") | ||
} | ||
|
||
result, err = MockPluginList.HasNewerVersionOf(&Mockplugina101) | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
|
||
if result { | ||
t.Errorf("Error in `HasNewerVersionOf`") | ||
} | ||
} | ||
|
||
func TestPluginsHelperImpl_PickLatestVersions(t *testing.T) { | ||
var h PluginsHelperImpl | ||
|
||
latestVersions, err := h.PickLatestVersions(MockPluginList) | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
|
||
if latestVersions.HasExactVersionOf(&Mockplugina100) { | ||
t.Errorf("Expected %s but got %s", Mockplugina101.Version, Mockplugina100.Version) | ||
} | ||
|
||
result, err := latestVersions.HasNewerVersionOf(&Mockplugina101) | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
|
||
if result { | ||
t.Errorf("Expected no newer version than %s", Mockplugina101.Version) | ||
} | ||
} | ||
|
||
func TestPluginsHelperImpl_FilterPlugins(t *testing.T) { | ||
var h PluginsHelperImpl | ||
|
||
MockPluginList.SetOrigin(&MockDashboard) | ||
installed, updated := h.FilterPlugins(&MockGrafana, MockPluginList) | ||
|
||
if !updated { | ||
t.Errorf("Expected plugins to be installed") | ||
} | ||
|
||
result := true | ||
result = result && installed.HasExactVersionOf(&Mockplugina101) | ||
result = result && installed.HasExactVersionOf(&Mockpluginb100) | ||
result = result && (len(MockDashboard.Status.Messages) == 2) | ||
result = result && (len(installed) == 2) | ||
|
||
if !result { | ||
t.Errorf("Unexpected plugins got installed") | ||
} | ||
} |
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,43 @@ | ||
package grafana | ||
|
||
import "github.com/integr8ly/grafana-operator/pkg/apis/integreatly/v1alpha1" | ||
|
||
var Mockplugina100 = v1alpha1.GrafanaPlugin{ | ||
Name: "a", | ||
Version: "1.0.0", | ||
} | ||
|
||
var Mockplugina101 = v1alpha1.GrafanaPlugin{ | ||
Name: "a", | ||
Version: "1.0.1", | ||
} | ||
|
||
var Mockplugina102 = v1alpha1.GrafanaPlugin{ | ||
Name: "a", | ||
Version: "1.0.2", | ||
} | ||
|
||
var Mockpluginb100 = v1alpha1.GrafanaPlugin{ | ||
Name: "b", | ||
Version: "1.0.0", | ||
} | ||
|
||
var Mockpluginc100 = v1alpha1.GrafanaPlugin{ | ||
Name: "c", | ||
Version: "1.0.0", | ||
} | ||
|
||
var MockPluginList = v1alpha1.PluginList{Mockplugina100, Mockplugina101, Mockpluginb100} | ||
|
||
var MockDashboard = v1alpha1.GrafanaDashboard{ | ||
Status: v1alpha1.GrafanaDashboardStatus{ | ||
Messages: []v1alpha1.GrafanaDashboardStatusMessage{}, | ||
}, | ||
} | ||
|
||
var MockGrafana = v1alpha1.Grafana{ | ||
Status: v1alpha1.GrafanaStatus{ | ||
Phase: 0, | ||
InstalledPlugins: v1alpha1.PluginList{}, | ||
}, | ||
} |
Oops, something went wrong.