mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-06-08 05:50:47 +00:00
File compression utils.
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
. "launchpad.net/gocheck"
|
||||
"os"
|
||||
)
|
||||
|
||||
type CompressSuite struct {
|
||||
tempfile *os.File
|
||||
}
|
||||
|
||||
var _ = Suite(&CompressSuite{})
|
||||
|
||||
func (s *CompressSuite) SetUpTest(c *C) {
|
||||
s.tempfile, _ = ioutil.TempFile(c.MkDir(), "aptly-test")
|
||||
s.tempfile.WriteString("Quick brown fox jumps over black dog and runs away... Really far away... who knows?")
|
||||
}
|
||||
|
||||
func (s *CompressSuite) TearDownTest(c *C) {
|
||||
s.tempfile.Close()
|
||||
}
|
||||
|
||||
func (s *CompressSuite) TestCompress(c *C) {
|
||||
err := CompressFile(s.tempfile)
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
st, err := os.Stat(s.tempfile.Name() + ".gz")
|
||||
c.Assert(err, IsNil)
|
||||
c.Assert(st.Size() < 100, Equals, true)
|
||||
|
||||
st, err = os.Stat(s.tempfile.Name() + ".bz2")
|
||||
c.Assert(err, IsNil)
|
||||
c.Assert(st.Size() < 120, Equals, true)
|
||||
}
|
||||
Reference in New Issue
Block a user