Skip to content

Commit

Permalink
test(functions): adds case for ohmyzsh (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
nyoungstudios authored Sep 14, 2024
1 parent f92fabe commit c53af52
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 0 deletions.
21 changes: 21 additions & 0 deletions functions/ohmyzsh/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,30 @@ Installs Oh My Zsh.

Accepts exactly 0 arguments

## Environment Variables

The Oh My Zsh [install script](https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh) respects these environment variables, and thus, they can be set in your config here.

`ZDOTDIR` - path to Zsh dotfiles directory (default: unset). See documentation below.

- <https://zsh.sourceforge.io/Doc/Release/Parameters.html#index-ZDOTDIR>
- <https://zsh.sourceforge.io/Doc/Release/Files.html#index-ZDOTDIR_002c-use-of>

`ZSH` - path to the Oh My Zsh repository folder (default: `$HOME/.oh-my-zsh`)

`REPO` - name of the GitHub repo to install from (default: `ohmyzsh/ohmyzsh`)

`REMOTE` - full remote URL of the git repo to install (default: GitHub via HTTPS)

`BRANCH` - branch to check out immediately after install (default: `master`)

## Example

```toml
[ ohmyzsh ]
options = []

# optionally configure environment variables
[ ohmyzsh.env ]
ZSH = "~/.custom-oh-my-zsh"
```
2 changes: 2 additions & 0 deletions functions/ohmyzsh/install.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/bash

install_ohmyzsh() {
# eval command to support evaluating environment variable strings passed from the config
export ZSH="$(eval echo ${ZSH:-})"
# install ohmyzsh
sh -c "$(curl_or_wget -s https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
}
44 changes: 44 additions & 0 deletions test/resources/functions/ohmyzsh/runners.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
[common]

os = "ubuntu-22.04"
image = "phusion/baseimage:jammy-1.0.4"

setup-tag = "setup"

[case.default.test]

assert-install-names = ["apt_get_packages", "ohmyzsh"]

[[case.default.test.commands]]

command = "bash"
arguments = [
"-ceu",
"[[ -d ~/.oh-my-zsh ]] && echo exists || echo missing",
]
assert-stdout-equals = "exists"

[[case.default.test.commands]]

command = "bash"
arguments = [
"-ceu",
"cat ~/.zshrc",
]
assert-stdout-contains = "ZSH_THEME=\"robbyrussell\""

[case.custom]
install-tag = "custom"

[case.custom.test]

assert-install-names = ["apt_get_packages", "ohmyzsh+custom"]

[[case.custom.test.commands]]

command = "zsh"
arguments = [
"-ceu",
"cd ~/.custom-oh-my-zsh && git config --get remote.origin.url",
]
assert-stdout-contains = "nyoungstudios/ohmyzsh"
18 changes: 18 additions & 0 deletions test/resources/functions/ohmyzsh/test_config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[ apt_get_packages ]
tags = [ "setup" ]
options = [
"--no-install-recommends",
"git",
"zsh"
]

[ ohmyzsh ]
options = []

[ "ohmyzsh+custom" ]
tags = [ "custom" ]
options = []

[ "ohmyzsh+custom".env ]
ZSH = "~/.custom-oh-my-zsh"
REPO = "nyoungstudios/ohmyzsh"

0 comments on commit c53af52

Please sign in to comment.