Skip to content

Commit

Permalink
Clean up test files
Browse files Browse the repository at this point in the history
  • Loading branch information
wulfgarpro committed Sep 13, 2023
1 parent 6004fba commit 8357f68
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
21 changes: 14 additions & 7 deletions test/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
FROM ubuntu:latest
FROM ubuntu:22.04

# Install system packages
RUN apt-get update && apt-get install -y \
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
curl \
git \
zsh \
gpg \
ripgrep
# Install oh-my-zsh
RUN sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
ripgrep \
&& rm -rf /var/lib/apt/lists/*

RUN mkdir -p /root/.oh-my-zsh/plugins/history-sync
# Install oh-my-zsh and history-sync plugin
RUN bash -c 'set -o pipefail' \
&& 'curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh | sh -e' \
&& mkdir -p /root/.oh-my-zsh/plugins/history-sync
COPY history-sync.plugin.zsh /root/.oh-my-zsh/plugins/history-sync/
# Install a basic `zshrc`
COPY test/zshrc /root/.zshrc
# Install the test script
COPY test/test.zsh /root
RUN chmod +x /root/test.zsh

ARG ACCESS_KEY
ENV ACCESS_KEY=${ACCESS_KEY}
ENTRYPOINT /usr/bin/zsh -i /root/test.zsh $ACCESS_KEY
ENTRYPOINT ["/usr/bin/zsh"]
CMD ["-i", "-c", "source /root/test.zsh ${ACCESS_KEY}"]
9 changes: 5 additions & 4 deletions test/test.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function success() {

function failure() {
echo $fg[red]"$1"$reset_color
exit 1
}

function info() {
Expand All @@ -23,22 +24,22 @@ function info() {

function check_fn_exists() {
typeset -f "$1" >/dev/null
[[ $? -eq 0 ]] || {failure "FAILURE: Function '$1' missing"; exit $?}
[[ $? -eq 0 ]] || {failure "FAILURE: Function '$1' missing"}
}

function check_alias_exists() {
alias "$1" >/dev/null
[[ $? -eq 0 ]] || {failure "FAILURE: Alias '$1' missing"; exit $?}
[[ $? -eq 0 ]] || {failure "FAILURE: Alias '$1' missing"}
}

function check_env_exists() {
[[ -v $1 ]]
[[ $? -eq 0 ]] || {failure "FAILURE: Environment variable '$1' missing"; exit $?}
[[ $? -eq 0 ]] || {failure "FAILURE: Environment variable '$1' missing"}
}

function check_history() {
rg -U "$1" ~/.zsh_history >/dev/null
[[ $? -eq 0 ]] || {failure "FAILURE: History did not match '$1'"; exit $?}
[[ $? -eq 0 ]] || {failure "FAILURE: History did not match '$1'"}
}

function setup() {
Expand Down

0 comments on commit 8357f68

Please sign in to comment.