mediaapi: Add thumbnail support (#132)
* vendor: Add bimg image processing library bimg is MIT licensed. It depends on the C library libvips which is LGPL v2.1+ licensed. libvips must be installed separately. * mediaapi: Add YAML config file support * mediaapi: Add thumbnail support * mediaapi: Add missing thumbnail files * travis: Add ppa and install libvips-dev * travis: Another ppa and install libvips-dev attempt * travis: Add sudo: required for sudo apt* usage * mediaapi/thumbnailer: Make comparison code more readable * mediaapi: Simplify logging of thumbnail properties * mediaapi/thumbnailer: Rename metrics to fitness Metrics is used in the context of monitoring with Prometheus so renaming to avoid confusion. * mediaapi/thumbnailer: Use math.Inf() for max aspect and size * mediaapi/thumbnailer: Limit number of parallel generators Fall back to selecting from already-/pre-generated thumbnails or serving the original. * mediaapi/thumbnailer: Split bimg code into separate file * vendor: Add github.com/nfnt/resize pure go image scaler * mediaapi/thumbnailer: Add nfnt/resize thumbnailer * travis: Don't install libvips-dev via ppa * mediaapi: Add notes to README about resizers * mediaapi: Elaborate on scaling libs in README
This commit is contained in:
parent
def49400bc
commit
2d202cec07
73 changed files with 10027 additions and 83 deletions
152
vendor/src/github.com/tj/go-debug/debug_test.go
vendored
Normal file
152
vendor/src/github.com/tj/go-debug/debug_test.go
vendored
Normal file
|
|
@ -0,0 +1,152 @@
|
|||
package debug
|
||||
|
||||
import "testing"
|
||||
import "strings"
|
||||
import "bytes"
|
||||
import "time"
|
||||
|
||||
func assertContains(t *testing.T, str, substr string) {
|
||||
if !strings.Contains(str, substr) {
|
||||
t.Fatalf("expected %q to contain %q", str, substr)
|
||||
}
|
||||
}
|
||||
|
||||
func assertNotContains(t *testing.T, str, substr string) {
|
||||
if strings.Contains(str, substr) {
|
||||
t.Fatalf("expected %q to not contain %q", str, substr)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDefault(t *testing.T) {
|
||||
var b []byte
|
||||
buf := bytes.NewBuffer(b)
|
||||
SetWriter(buf)
|
||||
|
||||
debug := Debug("foo")
|
||||
debug("something")
|
||||
debug("here")
|
||||
debug("whoop")
|
||||
|
||||
if buf.Len() != 0 {
|
||||
t.Fatalf("buffer should be empty")
|
||||
}
|
||||
}
|
||||
|
||||
func TestEnable(t *testing.T) {
|
||||
var b []byte
|
||||
buf := bytes.NewBuffer(b)
|
||||
SetWriter(buf)
|
||||
|
||||
Enable("foo")
|
||||
|
||||
debug := Debug("foo")
|
||||
debug("something")
|
||||
debug("here")
|
||||
debug("whoop")
|
||||
|
||||
if buf.Len() == 0 {
|
||||
t.Fatalf("buffer should have output")
|
||||
}
|
||||
|
||||
str := string(buf.Bytes())
|
||||
assertContains(t, str, "something")
|
||||
assertContains(t, str, "here")
|
||||
assertContains(t, str, "whoop")
|
||||
}
|
||||
|
||||
func TestMultipleOneEnabled(t *testing.T) {
|
||||
var b []byte
|
||||
buf := bytes.NewBuffer(b)
|
||||
SetWriter(buf)
|
||||
|
||||
Enable("foo")
|
||||
|
||||
foo := Debug("foo")
|
||||
foo("foo")
|
||||
|
||||
bar := Debug("bar")
|
||||
bar("bar")
|
||||
|
||||
if buf.Len() == 0 {
|
||||
t.Fatalf("buffer should have output")
|
||||
}
|
||||
|
||||
str := string(buf.Bytes())
|
||||
assertContains(t, str, "foo")
|
||||
assertNotContains(t, str, "bar")
|
||||
}
|
||||
|
||||
func TestMultipleEnabled(t *testing.T) {
|
||||
var b []byte
|
||||
buf := bytes.NewBuffer(b)
|
||||
SetWriter(buf)
|
||||
|
||||
Enable("foo,bar")
|
||||
|
||||
foo := Debug("foo")
|
||||
foo("foo")
|
||||
|
||||
bar := Debug("bar")
|
||||
bar("bar")
|
||||
|
||||
if buf.Len() == 0 {
|
||||
t.Fatalf("buffer should have output")
|
||||
}
|
||||
|
||||
str := string(buf.Bytes())
|
||||
assertContains(t, str, "foo")
|
||||
assertContains(t, str, "bar")
|
||||
}
|
||||
|
||||
func TestEnableDisable(t *testing.T) {
|
||||
var b []byte
|
||||
buf := bytes.NewBuffer(b)
|
||||
SetWriter(buf)
|
||||
|
||||
Enable("foo,bar")
|
||||
Disable()
|
||||
|
||||
foo := Debug("foo")
|
||||
foo("foo")
|
||||
|
||||
bar := Debug("bar")
|
||||
bar("bar")
|
||||
|
||||
if buf.Len() != 0 {
|
||||
t.Fatalf("buffer should not have output")
|
||||
}
|
||||
}
|
||||
|
||||
func ExampleEnable() {
|
||||
Enable("mongo:connection")
|
||||
Enable("mongo:*")
|
||||
Enable("foo,bar,baz")
|
||||
Enable("*")
|
||||
}
|
||||
|
||||
func ExampleDebug() {
|
||||
var debug = Debug("single")
|
||||
|
||||
for {
|
||||
debug("sending mail")
|
||||
debug("send email to %s", "tobi@segment.io")
|
||||
debug("send email to %s", "loki@segment.io")
|
||||
debug("send email to %s", "jane@segment.io")
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkDisabled(b *testing.B) {
|
||||
debug := Debug("something")
|
||||
for i := 0; i < b.N; i++ {
|
||||
debug("stuff")
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkNonMatch(b *testing.B) {
|
||||
debug := Debug("something")
|
||||
Enable("nonmatch")
|
||||
for i := 0; i < b.N; i++ {
|
||||
debug("stuff")
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue