Files
dokku/tests/unit/git_4.bats
Jose Diaz-Gonzalez 0a31f6fe3a feat: add git:from-image support
The new command superscedes the previous tags plugin, and integrates docker image deployment with the general build process.

While `docker image load` is not supported, this otherwise completely handles all previous workflows supported by the `tags:deploy` command, while doing so in a much easier to use interface.

Closes #4296
2021-03-01 02:26:58 -05:00

97 lines
2.5 KiB
Bash

#!/usr/bin/env bats
load test_helper
setup() {
global_setup
create_app
touch /home/dokku/.ssh/known_hosts
chown dokku:dokku /home/dokku/.ssh/known_hosts
}
teardown() {
rm -f /home/dokku/.ssh/id_rsa.pub || true
destroy_app
global_teardown
}
@test "(git) git:from-image [missing]" {
run /bin/bash -c "dokku git:from-image $TEST_APP dokku/python:missing-tag"
echo "output: $output"
echo "status: $status"
assert_failure
}
@test "(git) git:from-image [normal]" {
run /bin/bash -c "dokku git:from-image $TEST_APP linuxserver/foldingathome:7.5.1-ls1"
echo "output: $output"
echo "status: $status"
assert_success
}
@test "(git) git:from-image [normal-cnb]" {
run /bin/bash -c "dokku git:from-image $TEST_APP dokku/node-js-getting-started:latest"
echo "output: $output"
echo "status: $status"
assert_success
}
@test "(git) git:from-image [onbuild]" {
local TMP=$(mktemp -d "/tmp/dokku.me.XXXXX")
trap 'popd &>/dev/null || true; rm -rf "$TMP"' INT TERM
run /bin/bash -c "dokku storage:mount $TEST_APP /var/run/docker.sock:/var/run/docker.sock"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku git:from-image $TEST_APP gliderlabs/logspout:v3.2.13"
echo "output: $output"
echo "status: $status"
assert_failure
cat <<EOF >"$TMP/build.sh"
#!/bin/sh
set -e
apk add --update go build-base git mercurial ca-certificates
cd /src
go build -ldflags "-X main.Version=\$1" -o /bin/logspout
apk del go git mercurial build-base
rm -rf /root/go /var/cache/apk/*
# backwards compatibility
ln -fs /tmp/docker.sock /var/run/docker.sock
EOF
cat <<EOF >"$TMP/modules.go"
package main
import (
_ "github.com/gliderlabs/logspout/adapters/multiline"
_ "github.com/gliderlabs/logspout/adapters/raw"
_ "github.com/gliderlabs/logspout/adapters/syslog"
_ "github.com/gliderlabs/logspout/healthcheck"
_ "github.com/gliderlabs/logspout/httpstream"
_ "github.com/gliderlabs/logspout/routesapi"
_ "github.com/gliderlabs/logspout/transports/tcp"
_ "github.com/gliderlabs/logspout/transports/tls"
_ "github.com/gliderlabs/logspout/transports/udp"
)
EOF
run sudo chown -R dokku:dokku "$TMP"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku git:from-image --build-dir $TMP $TEST_APP gliderlabs/logspout:v3.2.13"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku git:from-image $TEST_APP gliderlabs/logspout:v3.2.13"
echo "output: $output"
echo "status: $status"
assert_failure
}