Skip to content

Commit

Permalink
filter reads to given run_id
Browse files Browse the repository at this point in the history
  • Loading branch information
MGibson1 committed Sep 26, 2024
1 parent 1b521af commit c8a565f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
18 changes: 16 additions & 2 deletions languages/python/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ def project_with_run_id(val: [dict]) -> [dict]:
return [dict(val, name=with_run_id(val["name"])) for val in val]


def filter_projects_to_this_run(projects: [ProjectResponse]) -> [ProjectResponse]:
if projects is None:
return None
return [project for project in projects if project.name.endswith(run_id)]


def filter_secrets_to_this_run(secrets: [SecretResponse]) -> [SecretResponse]:
if secrets is None:
return None
return [secret for secret in secrets if secret.key.endswith(run_id)]


def secret_with_run_id(val: [dict]) -> [dict]:
return [
dict(
Expand Down Expand Up @@ -100,7 +112,8 @@ def setUpClass(cls):

# Query for projects
cls.projects_response = cls.client.projects().list(organization_id)
cls.projects = getattr(cls.projects_response.data, "data", None)
cls.all_projects = getattr(cls.projects_response.data, "data", None)
cls.projects = filter_projects_to_this_run(cls.all_projects)
cls.mutable_projects_response = cls.mutable_client.projects().list(
organization_id
)
Expand Down Expand Up @@ -129,7 +142,8 @@ def setUpClass(cls):
cls.secrets_response = cls.client.secrets().get_by_ids(
[secret.id for secret in cls.list_response.data.data]
)
cls.secrets = getattr(cls.secrets_response.data, "data", None)
cls.all_secrets = getattr(cls.secrets_response.data, "data", None)
cls.secrets = filter_secrets_to_this_run(cls.all_secrets)
cls.list = getattr(cls.list_response.data, "data", None)

def test_list_response_is_success(self):
Expand Down
10 changes: 10 additions & 0 deletions languages/ruby/spec/e2e_data_manipulation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ def with_run_id(str)
"#{str}-#{run_id}"
end

def filter_projects_to_this_run(projects)
run_id = env('RUN_ID')
projects.filter { |p| p['name'].end_with? run_id }
end

def filter_secrets_to_this_run(secrets)
run_id = env('RUN_ID')
secrets.filter { |p| p['key'].end_with? run_id }
end

def project_with_run_id(project)
project['name'] = with_run_id project['name']
project
Expand Down
6 changes: 4 additions & 2 deletions languages/ruby/spec/e2e_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@
let(:expected_data) { JSON.parse(File.read(expected_data_file)) }
let(:expected_projects) { expected_data['projects'].map { |p| project_with_run_id p } }
let(:expected_secrets) { expected_data['secrets'].map { |s| secret_with_project_id(secret_with_run_id(s), projects) } }
let(:projects) { @client.projects.list(organization_id) }
let(:secrets) { @client.secrets.list(organization_id) }
let(:all_projects) { @client.projects.list(organization_id).filter }
let(:projects) { filter_projects_to_this_run(all_projects) }
let(:all_secrets) { @client.secrets.list(organization_id) }
let(:secrets) { filter_secrets_to_this_run(all_secrets) }

before(:all) do
# Set up client
Expand Down

0 comments on commit c8a565f

Please sign in to comment.