b53c8b27b6
There are some cases, notably in tests, where we do not want to write to the filesystem. In such cases, it's better to return an error and let each call site determine whether or not that error should be fatal. Add a NewReadOnlyConfig constructor that works the same way as the existing constructor, but simply sets a flag to block any writes. Make the functions that write to the filesystem go through a wrapper that checks for read-only status and have them fail.
15 lines
304 B
Go
15 lines
304 B
Go
package git_test // to avoid import cycles
|
|
|
|
import (
|
|
"testing"
|
|
|
|
. "github.com/git-lfs/git-lfs/git"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestReadOnlyConfig(t *testing.T) {
|
|
cfg := NewReadOnlyConfig("", "")
|
|
_, err := cfg.SetLocal("lfs.this.should", "fail")
|
|
assert.Equal(t, err, ErrReadOnly)
|
|
}
|