def test_other_build(self): write_session(self.build_name, self.session_id) next_build_name = '124' next_session_id = '/intake/organizations/launchableinc/workspaces/mothership/builds/123/test_sessions/14' write_session(next_build_name, next_session_id) self.assertEqual(read_session(next_build_name), next_session_id) self.assertEqual(read_session(self.build_name), self.session_id)
def test_subset_without_session(self): # emulate launchable record build write_build(self.build_name) pipe = "TestExample1\nTestExample2\nTestExample3\nTestExample4\nok github.com/launchableinc/rocket-car-gotest 0.268s" result = self.cli('subset', '--target', '10%', 'go-test', input=pipe) self.assertEqual(result.exit_code, 0) self.assertEqual(read_session(self.build_name), self.session) payload = json.loads( gzip.decompress(responses.calls[1].request.body).decode()) expected = self.load_json_from_file( self.test_files_dir.joinpath('subset_result.json')) self.assert_json_orderless_equal(expected, payload)
def test_subset(self): result = self.cli('subset', '--target', '10%', '--build', self.build_name, 'bazel', input=self.subset_input) self.assertEqual(result.exit_code, 0) self.assertEqual(read_session(self.build_name), self.session) payload = json.loads( gzip.decompress(responses.calls[1].request.body).decode()) expected = self.load_json_from_file( self.test_files_dir.joinpath('subset_result.json')) self.assert_json_orderless_equal(payload, expected)
def test_record_test(self): result = self.cli('record', 'tests', '--build', self.build_name, 'ctest', str(self.test_files_dir) + "/Testing/**/Test.xml") self.assertEqual(result.exit_code, 0) self.assertEqual(read_session(self.build_name), self.session) payload = json.loads( gzip.decompress(b''.join( responses.calls[1].request.body)).decode()) expected = self.load_json_from_file( self.test_files_dir.joinpath('record_test_result.json')) for c in payload['events']: del c['created_at'] self.assert_json_orderless_equal(payload, expected)
def test_record_test(self): # emulate launchable record build write_build(self.build_name) result = self.cli('record', 'tests', 'bazel', str(self.test_files_dir) + "/") self.assertEqual(result.exit_code, 0) self.assertEqual(read_session(self.build_name), self.session) payload = json.loads( gzip.decompress(responses.calls[2].request.body).decode()) expected = self.load_json_from_file( self.test_files_dir.joinpath('record_test_result.json')) for c in payload['events']: del c['created_at'] self.assert_json_orderless_equal(payload, expected)
def test_record_tests_without_session(self): result = self.cli('record', 'tests', '--build', self.build_name, 'go-test', str(self.test_files_dir) + "/") self.assertEqual(result.exit_code, 0) self.assertEqual(read_session(self.build_name), self.session) self.assertIn('events', responses.calls[1].request.url, 'call events API') payload = json.loads( gzip.decompress(b''.join( responses.calls[1].request.body)).decode()) for c in payload['events']: del c['created_at'] expected = self.load_json_from_file( self.test_files_dir.joinpath('record_test_result.json')) self.assert_json_orderless_equal(expected, payload) self.assertIn('close', responses.calls[2].request.url, 'call close API')
def test_read_before_write(self): self.assertEqual(read_session(self.build_name), None)
def test_write_read_remove(self): write_session(self.build_name, self.session_id) self.assertEqual(read_session(self.build_name), self.session_id) remove_session(self.build_name) self.assertEqual(read_session(self.build_name), None)