|
|
@@ -11,7 +11,9 @@ func TestPreparingReleaseFromRemote(t *testing.T) {
|
|
|
expectedOs := "linux"
|
|
|
buildArtifacts := []buildArtifact{{expectedOs,expectedArch, ".linux-amd64.tar.gz"}}
|
|
|
|
|
|
- builder := releaseFromExternalContent{
|
|
|
+ var builder releaseBuilder
|
|
|
+
|
|
|
+ builder = releaseFromExternalContent{
|
|
|
getter: mockHttpGetter{},
|
|
|
rawVersion: versionIn,
|
|
|
}
|
|
|
@@ -49,5 +51,60 @@ func (mockHttpGetter) getContents(url string) (string, error) {
|
|
|
|
|
|
|
|
|
func TestPreparingReleaseFromLocal(t *testing.T) {
|
|
|
+ whatsNewUrl := "https://whatsnews.foo/"
|
|
|
+ relNotesUrl := "https://relnotes.foo/"
|
|
|
+ expectedVersion := "5.4.0-123pre1"
|
|
|
+ expectedBuilds := 4
|
|
|
+
|
|
|
+ var builder releaseBuilder
|
|
|
+ builder = releaseLocalSources{
|
|
|
+ path: "local_test_data",
|
|
|
+ }
|
|
|
+
|
|
|
+ relAll, _ := builder.prepareRelease("https://s3-us-west-2.amazonaws.com/grafana-enterprise-releases/master/grafana-enterprise", whatsNewUrl, relNotesUrl, buildArtifactConfigurations)
|
|
|
+
|
|
|
+ if relAll.Stable || !relAll.Nightly {
|
|
|
+ t.Error("Expected a nightly release but wasn't.")
|
|
|
+ }
|
|
|
+
|
|
|
+ if relAll.ReleaseNotesUrl != relNotesUrl {
|
|
|
+ t.Errorf("expected releaseNotesUrl to be %s, but it was %s", relNotesUrl, relAll.ReleaseNotesUrl)
|
|
|
+ }
|
|
|
+ if relAll.WhatsNewUrl != whatsNewUrl {
|
|
|
+ t.Errorf("expected whatsNewUrl to be %s, but it was %s", whatsNewUrl, relAll.WhatsNewUrl)
|
|
|
+ }
|
|
|
|
|
|
+ if relAll.Beta {
|
|
|
+ t.Errorf("Expected release to be nightly, not beta.")
|
|
|
+ }
|
|
|
+
|
|
|
+ if relAll.Version != expectedVersion {
|
|
|
+ t.Errorf("Expected version=%s, but got=%s", expectedVersion, relAll.Version)
|
|
|
+ }
|
|
|
+
|
|
|
+ if len(relAll.Builds) != expectedBuilds {
|
|
|
+ t.Errorf("Expected %v builds, but was %v", expectedBuilds, len(relAll.Builds))
|
|
|
+ }
|
|
|
+
|
|
|
+ expectedArch := "amd64"
|
|
|
+ expectedOs := "win"
|
|
|
+ relOne, _ := builder.prepareRelease("https://s3-us-west-2.amazonaws.com/grafana-enterprise-releases/master/grafana-enterprise", whatsNewUrl, relNotesUrl, []buildArtifact{{
|
|
|
+ os: expectedOs,
|
|
|
+ arch: expectedArch,
|
|
|
+ urlPostfix: ".windows-amd64.zip",
|
|
|
+ }})
|
|
|
+
|
|
|
+ if len(relOne.Builds) != 1 {
|
|
|
+ t.Errorf("Expected 1 artifact, but was %v", len(relOne.Builds))
|
|
|
+ }
|
|
|
+
|
|
|
+ build := relOne.Builds[0]
|
|
|
+
|
|
|
+ if build.Arch != expectedArch {
|
|
|
+ t.Fatalf("Expected arch to be %s, but was %s", expectedArch, build.Arch)
|
|
|
+ }
|
|
|
+
|
|
|
+ if build.Os != expectedOs {
|
|
|
+ t.Fatalf("Expected os to be %s, but was %s", expectedOs, build.Os)
|
|
|
+ }
|
|
|
}
|