Skip to content

Commit

Permalink
tests: add tests for #22
Browse files Browse the repository at this point in the history
Signed-off-by: scnace <scbizu@gmail.com>
  • Loading branch information
scbizu committed Oct 16, 2020
1 parent e6eb55b commit 89273e5
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 0 deletions.
48 changes: 48 additions & 0 deletions acceptance_tests/lib/ChartMuseum.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,25 @@ def upload_test_charts(self):
self.http_status_code_should_be(201, response.status_code)
os.chdir('../')

def upload_test_more_version_charts(self):
charts_endpoint = '%s/api/charts' % common.HELM_REPO_URL
testcharts_dir = os.path.join(self.rootdir, common.TESTMOREVERSIONCHARTS_DIR)
os.chdir(testcharts_dir)
for d in os.listdir('.'):
if not os.path.isdir(d):
continue
os.chdir(d)
tgzs = glob.glob('*.tgz')
for tgz in tgzs:
print(('Uploading more version chart package "%s"' % tgz))
with open(tgz, 'rb') as f:
response = requests.post(url=charts_endpoint, data=f.read())
print(('POST %s' % charts_endpoint))
print(('HTTP STATUS: %s' % response.status_code))
print(('HTTP CONTENT: %s' % response.content))
self.http_status_code_should_be(201, response.status_code)
os.chdir('../')

def upload_bad_test_charts(self):
charts_endpoint = '%s/api/charts' % common.HELM_REPO_URL
testcharts_dir = os.path.join(self.rootdir, common.TESTBADCHARTS_DIR)
Expand Down Expand Up @@ -167,3 +186,32 @@ def delete_test_charts(self):
print(('HTTP CONTENT: %s' % response.content))
self.http_status_code_should_be(200, response.status_code)
os.chdir('../')

def delete_test_version_charts(self):
endpoint = '%s/api/charts' % common.HELM_REPO_URL
testcharts_dir = os.path.join(self.rootdir, common.TESTMOREVERSIONCHARTS_DIR)
os.chdir(testcharts_dir)
for d in os.listdir('.'):
if not os.path.isdir(d):
continue
os.chdir(d)
f = open("Chart.yaml","r")
name = ''
version = ''
for lines in f:
v_prefix = 'version: '
name_prefix = 'name: '
if lines.startswith(v_prefix)
version = lines[len(prefix):]
elif lines.startswith(name_prefix):
name = lines[len(prefix):]
print(('Delete test chart "%s-%s"' % (name, version)))
epoint = '%s/%s/%s' % (endpoint, name, version)
response = requests.delete(url=epoint)
print(('HTTP STATUS: %s' % response.status_code))
print(('HTTP CONTENT: %s' % response.content))
self.http_status_code_should_be(200, response.status_code)
# checks if the chart still exists
response = requests.get(url=epoint)
self.http_status_code_should_be(404, response.status_code)
os.chdir('../')
1 change: 1 addition & 0 deletions acceptance_tests/lib/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
HELM_REPO_URL = 'http://localhost:%d' % PORT
TESTCHARTS_DIR = 'testdata/charts'
TESTBADCHARTS_DIR = 'testdata/badcharts'
TESTMOREVERSIONCHARTS_DIR = 'testdata/charts/mychart2'
ACCEPTANCE_DIR = '.acceptance/'
STORAGE_DIR = os.path.join(ACCEPTANCE_DIR, 'storage/')
KEYRING = 'testdata/pgp/helm-test-key.pub'
Expand Down
2 changes: 2 additions & 0 deletions testdata/charts/mychart2/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.tgz
*.prov
2 changes: 2 additions & 0 deletions testdata/charts/mychart2/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name: mychart2
version: 0.1.0-SNAPSHOT-1
9 changes: 9 additions & 0 deletions testdata/charts/mychart2/templates/pod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v1
kind: Pod
metadata:
name: '{{- printf "%s-%s" .Release.Name .Chart.Name | trunc 63 | trimSuffix "-" -}}'
spec:
containers:
- image: busybox
name: '{{ .Chart.Name }}'
command: ['/bin/sh', '-c', 'while true; do echo {{ .Release.Name }}; sleep 5; done']

0 comments on commit 89273e5

Please sign in to comment.