mirror of
https://github.com/nmattia/snack.git
synced 2024-09-11 11:55:36 +03:00
Add test for non-Nix-friendly paths
This commit is contained in:
parent
296834e52d
commit
5f905d15da
@ -109,6 +109,11 @@ pushd tests/readme
|
||||
./test
|
||||
popd
|
||||
|
||||
banner "Test that paths can be non-nix-friendly"
|
||||
pushd tests/any-paths
|
||||
./test
|
||||
popd
|
||||
|
||||
banner "Test this file's formatting"
|
||||
list=$(shfmt -i 2 -l script/test)
|
||||
if [[ -n "$list" ]]; then
|
||||
|
6
tests/any-paths/app/Main.hs
Normal file
6
tests/any-paths/app/Main.hs
Normal file
@ -0,0 +1,6 @@
|
||||
module Main where
|
||||
|
||||
import Lib
|
||||
|
||||
main :: IO ()
|
||||
main = topReddit >>= print
|
17
tests/any-paths/package.yaml
Normal file
17
tests/any-paths/package.yaml
Normal file
@ -0,0 +1,17 @@
|
||||
name: snack-readme
|
||||
|
||||
dependencies:
|
||||
- lens
|
||||
- wreq
|
||||
|
||||
library:
|
||||
source-dirs: ./src
|
||||
|
||||
executable:
|
||||
main: Main.hs
|
||||
source-dirs: ./app
|
||||
dependencies:
|
||||
- snack-readme
|
||||
|
||||
default-extensions:
|
||||
- OverloadedStrings
|
12
tests/any-paths/snack.nix
Normal file
12
tests/any-paths/snack.nix
Normal file
@ -0,0 +1,12 @@
|
||||
let
|
||||
lib =
|
||||
{ src = ./src;
|
||||
dependencies = [ "wreq" "lens" ];
|
||||
extensions = [ "OverloadedStrings"];
|
||||
};
|
||||
in
|
||||
{ main = "Main";
|
||||
src = ./app;
|
||||
packages = [ lib ];
|
||||
dependencies = [ "wreq" "lens" ];
|
||||
}
|
22
tests/any-paths/src/Lib.hs
Normal file
22
tests/any-paths/src/Lib.hs
Normal file
@ -0,0 +1,22 @@
|
||||
module Lib where
|
||||
|
||||
import Control.Lens
|
||||
import Network.Wreq
|
||||
import Data.Aeson.Lens
|
||||
import Data.Text (Text)
|
||||
|
||||
topReddit :: IO Text
|
||||
topReddit =
|
||||
getWith opts url
|
||||
<&> (^. responseBody
|
||||
. key "data"
|
||||
. key "children"
|
||||
. nth 0
|
||||
. key "data"
|
||||
. key "title"
|
||||
. _String)
|
||||
where
|
||||
url = "https://www.reddit.com/r/haskell/top.json"
|
||||
opts = defaults
|
||||
& param "limit" .~ ["1"]
|
||||
& param "t" .~ ["all"]
|
12
tests/any-paths/test
Executable file
12
tests/any-paths/test
Executable file
@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env bash
|
||||
# vim: ft=sh sw=2 et
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
test() {
|
||||
echo | $SNACK ghci
|
||||
$SNACK run
|
||||
}
|
||||
|
||||
SNACK="snack -s snack.nix" test
|
||||
SNACK="snack --package-yaml package.yaml" test
|
Loading…
Reference in New Issue
Block a user