File indexing completed on 2024-04-21 05:08:04

0001 #!/usr/bin/env ruby
0002 # frozen_string_literal: true
0003 #
0004 # Copyright (C) 2017 Harald Sitter <sitter@kde.org>
0005 #
0006 # This library is free software; you can redistribute it and/or
0007 # modify it under the terms of the GNU Lesser General Public
0008 # License as published by the Free Software Foundation; either
0009 # version 2.1 of the License, or (at your option) version 3, or any
0010 # later version accepted by the membership of KDE e.V. (or its
0011 # successor approved by the membership of KDE e.V.), which shall
0012 # act as a proxy defined in Section 6 of version 3 of the license.
0013 #
0014 # This library is distributed in the hope that it will be useful,
0015 # but WITHOUT ANY WARRANTY; without even the implied warranty of
0016 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0017 # Lesser General Public License for more details.
0018 #
0019 # You should have received a copy of the GNU Lesser General Public
0020 # License along with this library.  If not, see <http://www.gnu.org/licenses/>.
0021 
0022 require 'minitest/autorun'
0023 
0024 require 'fileutils'
0025 require 'tmpdir'
0026 
0027 require_relative 'extend_content'
0028 
0029 class TestExtendContent < Minitest::Test
0030   def setup
0031     @tmpdir = Dir.mktmpdir
0032     Dir.chdir(@tmpdir)
0033   end
0034 
0035   def teardown
0036     FileUtils.rm_rf(@tmpdir)
0037   end
0038 
0039   def test_extend
0040     FileUtils.mkpath('parts/kf5/ubuntu/download')
0041     FileUtils.touch('parts/kf5/ubuntu/download/foo_bar_1.0_amd64.deb')
0042     FileUtils.touch('parts/kf5/ubuntu/download/meow_1_amd64.deb')
0043     FileUtils.mkpath('parts/kf5-dev/ubuntu/download')
0044     FileUtils.touch('parts/kf5-dev/ubuntu/download/kitteh_1_amd64.deb')
0045 
0046     File.write('stage-content.json', JSON.generate(%w(a)))
0047     File.write('stage-dev.json', JSON.generate(%w(b)))
0048 
0049     Content.extend
0050 
0051     data = JSON.parse(File.read('stage-content.json'))
0052     assert_equal(%w(foo_bar meow a).sort, data.sort)
0053 
0054     data = JSON.parse(File.read('stage-dev.json'))
0055     assert_equal(%w(b kitteh).sort, data.sort)
0056   end
0057 end