require 'test_helper'
class ContainerTest < ActiveSupport::TestCase
+ def minimal_new
+ c = Container.new
+ c.command = ["echo", "foo"]
+ c.container_image = "img"
+ c.output_path = "/tmp"
+ c
+ end
+
def check_illegal_modify c
c.reload
c.command = ["echo", "bar"]
test "Container create" do
act_as_system_user do
- c = Container.new
- c.command = ["echo", "foo"]
- c.container_image = "img"
- c.cwd = "/tmp"
+ c = minimal_new
c.environment = {}
c.mounts = {"BAR" => "FOO"}
c.output_path = "/tmp"
test "Container running" do
act_as_system_user do
- c = Container.new
- c.command = ["echo", "foo"]
- c.container_image = "img"
- c.output_path = "/tmp"
+ c = minimal_new
c.save!
c.reload
test "Container queued cancel" do
act_as_system_user do
- c = Container.new
- c.command = ["echo", "foo"]
- c.container_image = "img"
- c.output_path = "/tmp"
+ c = minimal_new
c.save!
c.reload
test "Container running cancel" do
act_as_system_user do
- c = Container.new
- c.command = ["echo", "foo"]
- c.container_image = "img"
- c.output_path = "/tmp"
+ c = minimal_new
c.save!
c.reload
test "Container create forbidden for non-admin" do
set_user_from_auth :active_trustedclient
- c = Container.new
- c.command = ["echo", "foo"]
- c.container_image = "img"
- c.cwd = "/tmp"
+ c = minimal_new
c.environment = {}
c.mounts = {"BAR" => "FOO"}
c.output_path = "/tmp"
test "Container only set exit code on complete" do
act_as_system_user do
- c = Container.new
- c.command = ["echo", "foo"]
- c.container_image = "img"
- c.output_path = "/tmp"
+ c = minimal_new
c.save!
c.reload