Class: SavedAssetTest

Inherits:
Minitest::Test
  • Object
show all
Defined in:
lib/saved_assets.rb

Instance Method Summary collapse

Instance Method Details

#test_script_name_with_special_characters_in_blocknameObject



73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/saved_assets.rb', line 73

def test_script_name_with_special_characters_in_blockname
  filename = 'sample.txt'
  prefix = 'test'
  time = Time.new(2023, 1, 1, 12, 0, 0)
  blockname = 'block/1:2'

  expected_name = 'test_2023-01-01-12-00-00_sample_txt_~_block_1_2_.*'
  assert_equal expected_name, MarkdownExec::SavedAsset.new(
    blockname: blockname, filename: filename, prefix: prefix,
    saved_asset_format: SAVED_ASSET_FORMAT, time: time
  ).generate_name
end

#test_stdout_name_with_special_characters_in_blocknameObject



86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/saved_assets.rb', line 86

def test_stdout_name_with_special_characters_in_blockname
  filename = 'sample.txt'
  prefix = 'test'
  time = Time.new(2023, 1, 1, 12, 0, 0)
  blockname = 'block/1:2'

  expected_name = 'test_2023-01-01-12-00-00_sample_txt_~_block_1_2_.*'
  assert_equal expected_name, MarkdownExec::SavedAsset.new(
    saved_asset_format: SAVED_ASSET_FORMAT,
    filename: filename, prefix: prefix, time: time, blockname: blockname
  ).generate_name
end

#test_wildcard_name_with_all_missingObject



164
165
166
167
168
169
170
171
172
173
174
175
# File 'lib/saved_assets.rb', line 164

def test_wildcard_name_with_all_missing
  filename = nil
  prefix = nil
  time = nil
  blockname = nil
  expected_wildcard = '*_*_*_~_*_.*'

  assert_equal expected_wildcard, MarkdownExec::SavedAsset.new(
    saved_asset_format: SAVED_ASSET_FORMAT,
    filename: filename, prefix: prefix, time: time, blockname: blockname
  ).generate_name
end

#test_wildcard_name_with_all_parametersObject



99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/saved_assets.rb', line 99

def test_wildcard_name_with_all_parameters
  filename = 'sample.txt'
  prefix = 'test'
  time = Time.new(2023, 1, 1, 12, 0, 0)
  blockname = 'block/1:2'
  expected_wildcard = 'test_2023-01-01-12-00-00_sample_txt_~_block_1_2_.*'

  assert_equal expected_wildcard, MarkdownExec::SavedAsset.new(
    saved_asset_format: SAVED_ASSET_FORMAT,
    filename: filename, prefix: prefix, time: time, blockname: blockname
  ).generate_name
end

#test_wildcard_name_with_missing_blocknameObject



151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/saved_assets.rb', line 151

def test_wildcard_name_with_missing_blockname
  filename = 'sample.txt'
  prefix = 'test'
  time = Time.new(2023, 1, 1, 12, 0, 0)
  blockname = nil
  expected_wildcard = 'test_2023-01-01-12-00-00_sample_txt_~_*_.*'

  assert_equal expected_wildcard, MarkdownExec::SavedAsset.new(
    saved_asset_format: SAVED_ASSET_FORMAT,
    filename: filename, prefix: prefix, time: time, blockname: blockname
  ).generate_name
end

#test_wildcard_name_with_missing_filenameObject



125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/saved_assets.rb', line 125

def test_wildcard_name_with_missing_filename
  filename = nil
  prefix = 'test'
  time = Time.new(2023, 1, 1, 12, 0, 0)
  blockname = 'block/1:2'
  expected_wildcard = 'test_2023-01-01-12-00-00_*_~_block_1_2_.*'

  assert_equal expected_wildcard, MarkdownExec::SavedAsset.new(
    saved_asset_format: SAVED_ASSET_FORMAT,
    filename: filename, prefix: prefix, time: time, blockname: blockname
  ).generate_name
end

#test_wildcard_name_with_missing_prefixObject



138
139
140
141
142
143
144
145
146
147
148
149
# File 'lib/saved_assets.rb', line 138

def test_wildcard_name_with_missing_prefix
  filename = 'sample.txt'
  prefix = nil
  time = Time.new(2023, 1, 1, 12, 0, 0)
  blockname = 'block/1:2'
  expected_wildcard = '*_2023-01-01-12-00-00_sample_txt_~_block_1_2_.*'

  assert_equal expected_wildcard, MarkdownExec::SavedAsset.new(
    saved_asset_format: SAVED_ASSET_FORMAT,
    filename: filename, prefix: prefix, time: time, blockname: blockname
  ).generate_name
end

#test_wildcard_name_with_missing_timeObject



112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/saved_assets.rb', line 112

def test_wildcard_name_with_missing_time
  filename = 'sample.txt'
  prefix = 'test'
  time = nil
  blockname = 'block/1:2'
  expected_wildcard = 'test_*_sample_txt_~_block_1_2_.*'

  assert_equal expected_wildcard, MarkdownExec::SavedAsset.new(
    saved_asset_format: SAVED_ASSET_FORMAT,
    filename: filename, prefix: prefix, time: time, blockname: blockname
  ).generate_name
end