storage_test.go 934 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // Copyright 2020 The Gogs Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package lfsutil
  5. import (
  6. "runtime"
  7. "testing"
  8. "github.com/stretchr/testify/assert"
  9. )
  10. func TestStorageLocalPath(t *testing.T) {
  11. if runtime.GOOS == "windows" {
  12. t.Skip("Skipping testing on Windows")
  13. return
  14. }
  15. tests := []struct {
  16. name string
  17. root string
  18. oid OID
  19. expPath string
  20. }{
  21. {
  22. name: "invalid oid",
  23. oid: OID("bad_oid"),
  24. },
  25. {
  26. name: "valid oid",
  27. root: "/lfs-objects",
  28. oid: OID("sha256:ef797c8118f02dfb649607dd5d3f8c7623048c9c063d532cc95c5ed7a898a64f"),
  29. expPath: "/lfs-objects/e/f/ef797c8118f02dfb649607dd5d3f8c7623048c9c063d532cc95c5ed7a898a64f",
  30. },
  31. }
  32. for _, test := range tests {
  33. t.Run(test.name, func(t *testing.T) {
  34. assert.Equal(t, test.expPath, StorageLocalPath(test.root, test.oid))
  35. })
  36. }
  37. }