1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
7 class AppVersionTest < ActiveSupport::TestCase
9 setup do AppVersion.forget end
11 teardown do AppVersion.forget end
13 test 'invoke git processes only on first call' do
14 AppVersion.expects(:git).
15 with("status", "--porcelain").once.
16 yields " M services/api/README\n"
17 AppVersion.expects(:git).
18 with("log", "-n1", "--format=%H").once.
19 yields "da39a3ee5e6b4b0d3255bfef95601890afd80709\n"
23 assert_equal 'da39a3ee-modified', v
27 test 'override with configuration "foobar"' do
28 Rails.configuration.source_version = 'foobar'
29 assert_equal 'foobar', AppVersion.hash
32 test 'override with configuration false' do
33 Rails.configuration.source_version = false
34 assert_not_equal 'foobar', AppVersion.hash
37 test 'override with file' do
38 path = Rails.root.join 'git-commit.version'
39 assert(!File.exist?(path),
40 "Packaged version file found in source tree: #{path}")
42 File.open(path, 'w') do |f|
43 f.write "0.1.abc123\n"
45 assert_equal "0.1.abc123", AppVersion.hash