mikelangelo-project / capstan

Capstan, a tool for packaging and running your application on OSv.
http://osv.io/capstan/
Other
19 stars 7 forks source link

Unit test `capstan package build` #26

Closed miha-plesko closed 7 years ago

miha-plesko commented 7 years ago

We introduce a utility function PrepareFiles that knows how to realize a file-structure recipe written as a simple map. E.g.

recipe = {
  "/myfolder/myfile.txt"           => "Foo",
  "/meta/run.yaml"                 => "runtime: node",
  "/node_modules/module/README.md" => "# Instructions"
}

is realized into:

root
  |- myfolder
     |- myfile.txt  # "Foo"
  |- meta
     |- run.yaml  # "runtime: node"
  |- node_modules
     |- module
        |- README.md # "# Instructions"

The idea is that gocheck framework prepares a temporary directory and calls this function to create package files; each test case gets it fresh and it's automatically deleted afterwards.

With this commit we also introduce a custom Checker (extends gocheck library), TarGzEquals, that checks whether content of tar.gz file is a realization of given recipe.

miha-plesko commented 7 years ago

@gberginc I think we forgot to click merge button on this one. Just wanted to add another similar test for capstan package describe here and noticed this is not in master yet. Please take a look.