Skip to content

Commit 3bb57f6

Browse files
committed
test to validate platform values in index yaml
1 parent 6f13e44 commit 3bb57f6

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

repo_index_test.go

+16
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"encoding/hex"
55
"io/ioutil"
66
"os"
7+
"strings"
78

89
"github.com/cloudfoundry-incubator/cli-plugin-repo/web"
910

@@ -57,6 +58,21 @@ var _ = Describe("Database", func() {
5758
}
5859
})
5960

61+
It("validates the platforms for every binary", func() {
62+
for _, plugin := range plugins.Plugins {
63+
for _, binary := range plugin.Binaries {
64+
Expect(web.ValidPlatforms).To(
65+
ContainElement(binary.Platform),
66+
fmt.Sprintf(
67+
"Plunin '%s' contains a platform '%s' that is invalid. Please use one of the following: '%s'",
68+
plugin.Name,
69+
binary.Platform,
70+
strings.Join(web.ValidPlatforms, ", "),
71+
))
72+
}
73+
}
74+
})
75+
6076
It("every binary download had a matching sha1", func() {
6177
if os.Getenv("BINARY_VALIDATION") != "true" {
6278
Skip("Skipping SHA1 binary checking. To enable, set the BINARY_VALIDATION env variable to 'true'")

web/plugins.go

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package web
22

33
import "time"
44

5+
var ValidPlatforms = []string{"osx", "linux32", "linux64", "win32", "win64"}
6+
57
type Plugin struct {
68
Name string `json:"name"`
79
Description string `json:"description"`

0 commit comments

Comments
 (0)