5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-07-01 12:36:08 +00:00
panel/test/models/deploy_local_test.rb
2021-08-07 18:25:54 -03:00

45 lines
1.2 KiB
Ruby

# frozen_string_literal: true
require 'test_helper'
class DeployLocalTest < ActiveSupport::TestCase
setup do
@site = create :site
end
teardown do
@site&.destroy
end
test 'se pueden crear' do
assert @site.deploy_local.valid?
assert_equal @site.hostname, @site.deploy_local.hostname
end
test 'no se puede cambiar el hostname' do
hostname = @site.deploy_local.hostname
@site.deploy_local.hostname = SecureRandom.hex
assert @site.deploy_local.save
assert_equal hostname, @site.deploy_local.hostname
end
test 'se puede deployear' do
deploy_local = @site.deploy_local
assert deploy_local.deploy
assert File.directory?(deploy_local.destination)
assert File.exist?(File.join(deploy_local.destination, 'index.html'))
assert_equal 3, deploy_local.build_stats.count
assert deploy_local.build_stats.map(&:bytes).compact.inject(:+).positive?
assert deploy_local.build_stats.map(&:seconds).compact.inject(:+).positive?
end
test 'al eliminarlos se elimina el directorio' do
deploy_local = @site.deploy_local
assert deploy_local.destroy
assert_not File.directory?(deploy_local.destination)
end
end