• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pulibrary / tigerdata-app / 2019cefc-a8e6-4859-80c7-47af78cd7e4c

07 Nov 2025 06:12PM UTC coverage: 88.239% (-3.1%) from 91.357%
2019cefc-a8e6-4859-80c7-47af78cd7e4c

Pull #2163

circleci

web-flow
Merge branch 'main' into 2157-project-list-error
Pull Request #2163: Logs Mediaflux errors when fetching the project list

8 of 8 new or added lines in 1 file covered. (100.0%)

498 existing lines in 29 files now uncovered.

2761 of 3129 relevant lines covered (88.24%)

488.86 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/app/services/test_asset_generator.rb
1
# frozen_string_literal: true
UNCOV
2
class TestAssetGenerator
1✔
UNCOV
3
  attr_reader :levels, :base_name, :file_count_per_directory, :directory_per_level, :mediaflux_session
1✔
UNCOV
4
  def initialize(user:, project_id:, levels: 5, directory_per_level: 100, file_count_per_directory: 1000)
1✔
UNCOV
5
    @user = user
6✔
UNCOV
6
    @project = Project.find(project_id)
6✔
UNCOV
7
    @levels = levels
6✔
UNCOV
8
    @directory_per_level = directory_per_level
6✔
UNCOV
9
    @file_count_per_directory = file_count_per_directory
6✔
10
    # Only use the last part of the path as the base (so we don't get the root "tigerdata/")
UNCOV
11
    @base_name = @project.project_directory_short.split("/").last
6✔
UNCOV
12
    @mediaflux_session = @user.mediaflux_session
6✔
UNCOV
13
  end
14

UNCOV
15
  def generate
1✔
UNCOV
16
    generate_level(@project.mediaflux_id, levels)
6✔
UNCOV
17
  end
18

UNCOV
19
  private
1✔
20

UNCOV
21
    def generate_level(parent_id, level)
1✔
UNCOV
22
      return if level == 0
18✔
UNCOV
23
      collection = Mediaflux::AssetCreateRequest.new(session_token: mediaflux_session, name: "#{base_name}-#{level}", pid: parent_id)
12✔
UNCOV
24
      collection_id = collection.id  # resolves the request and extracts the id
12✔
UNCOV
25
      generate_directory(collection_id, directory_per_level)
12✔
UNCOV
26
      generate_level(collection_id, level - 1)
12✔
UNCOV
27
    end
28

UNCOV
29
    def generate_directory(parent_id, directory_count)
1✔
UNCOV
30
      return if directory_count == 0
36✔
UNCOV
31
      name_extention = (0...10).map { ("a".."z").to_a[rand(26)] }.join
264✔
UNCOV
32
      dir_collection = Mediaflux::AssetCreateRequest.new(session_token: mediaflux_session, name: "#{base_name}-#{parent_id}-#{name_extention}", pid: parent_id)
24✔
UNCOV
33
      dir_collection_id = dir_collection.id
24✔
UNCOV
34
      raise dir_collection.response_error.to_s if dir_collection_id.blank?
24✔
UNCOV
35
      Mediaflux::TestAssetCreateRequest.new(session_token: mediaflux_session, parent_id: dir_collection_id, count: file_count_per_directory).resolve
24✔
UNCOV
36
      generate_directory(parent_id, directory_count - 1)
24✔
UNCOV
37
    end
UNCOV
38
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc