auto_test.go 811 B

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright (C) 2014 The Syncthing Authors.
  2. //
  3. // This Source Code Form is subject to the terms of the Mozilla Public
  4. // License, v. 2.0. If a copy of the MPL was not distributed with this file,
  5. // You can obtain one at https://mozilla.org/MPL/2.0/.
  6. package auto_test
  7. import (
  8. "bytes"
  9. "compress/gzip"
  10. "io"
  11. "strings"
  12. "testing"
  13. "github.com/syncthing/syncthing/lib/api/auto"
  14. )
  15. func TestAssets(t *testing.T) {
  16. assets := auto.Assets()
  17. idx, ok := assets["default/index.html"]
  18. if !ok {
  19. t.Fatal("No index.html in compiled in assets")
  20. }
  21. if !idx.Gzipped {
  22. t.Fatal("default/index.html should be compressed")
  23. }
  24. var gr *gzip.Reader
  25. gr, _ = gzip.NewReader(strings.NewReader(idx.Content))
  26. html, _ := io.ReadAll(gr)
  27. if !bytes.Contains(html, []byte("<html")) {
  28. t.Fatal("No html in index.html")
  29. }
  30. }