forked from golang-migrate/migrate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add httpfs.New() constructor with delayed errors
This PR adds a new httpfs source driver constructor New(). It is identical to the WithInstance() constructor but will postpone any errors until the driver is actually being used. This allows clients of this package to have less error checks without loosing correctness. In addition this PR adds more tests, improves test code coverage, and makes golinter happy by removing deferred Close call.
- Loading branch information
Showing
8 changed files
with
197 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
mode: set | ||
github.com/golang-migrate/migrate/v4/source/httpfs/driver.go:27.57,29.16 2 1 | ||
github.com/golang-migrate/migrate/v4/source/httpfs/driver.go:32.2,32.10 1 1 | ||
github.com/golang-migrate/migrate/v4/source/httpfs/driver.go:29.16,31.3 1 1 | ||
github.com/golang-migrate/migrate/v4/source/httpfs/driver.go:37.75,39.2 1 1 | ||
github.com/golang-migrate/migrate/v4/source/httpfs/driver.go:41.66,43.16 2 1 | ||
github.com/golang-migrate/migrate/v4/source/httpfs/driver.go:46.2,49.16 3 1 | ||
github.com/golang-migrate/migrate/v4/source/httpfs/driver.go:53.2,54.29 2 1 | ||
github.com/golang-migrate/migrate/v4/source/httpfs/driver.go:69.2,73.8 1 1 | ||
github.com/golang-migrate/migrate/v4/source/httpfs/driver.go:43.16,45.3 1 1 | ||
github.com/golang-migrate/migrate/v4/source/httpfs/driver.go:49.16,51.3 1 1 | ||
github.com/golang-migrate/migrate/v4/source/httpfs/driver.go:54.29,55.19 1 1 | ||
github.com/golang-migrate/migrate/v4/source/httpfs/driver.go:59.3,60.17 2 1 | ||
github.com/golang-migrate/migrate/v4/source/httpfs/driver.go:64.3,64.20 1 1 | ||
github.com/golang-migrate/migrate/v4/source/httpfs/driver.go:55.19,56.12 1 1 | ||
github.com/golang-migrate/migrate/v4/source/httpfs/driver.go:60.17,61.12 1 1 | ||
github.com/golang-migrate/migrate/v4/source/httpfs/driver.go:64.20,66.4 1 1 | ||
github.com/golang-migrate/migrate/v4/source/httpfs/driver.go:79.58,81.2 1 1 | ||
github.com/golang-migrate/migrate/v4/source/httpfs/driver.go:84.32,86.2 1 1 | ||
github.com/golang-migrate/migrate/v4/source/httpfs/driver.go:89.52,90.45 1 1 | ||
github.com/golang-migrate/migrate/v4/source/httpfs/driver.go:93.2,97.3 1 0 | ||
github.com/golang-migrate/migrate/v4/source/httpfs/driver.go:90.45,92.3 1 1 | ||
github.com/golang-migrate/migrate/v4/source/httpfs/driver.go:101.67,102.51 1 1 | ||
github.com/golang-migrate/migrate/v4/source/httpfs/driver.go:105.2,109.3 1 1 | ||
github.com/golang-migrate/migrate/v4/source/httpfs/driver.go:102.51,104.3 1 1 | ||
github.com/golang-migrate/migrate/v4/source/httpfs/driver.go:113.67,114.51 1 1 | ||
github.com/golang-migrate/migrate/v4/source/httpfs/driver.go:117.2,121.3 1 1 | ||
github.com/golang-migrate/migrate/v4/source/httpfs/driver.go:114.51,116.3 1 1 | ||
github.com/golang-migrate/migrate/v4/source/httpfs/driver.go:125.87,127.9 2 1 | ||
github.com/golang-migrate/migrate/v4/source/httpfs/driver.go:134.2,135.16 2 1 | ||
github.com/golang-migrate/migrate/v4/source/httpfs/driver.go:138.2,138.32 1 1 | ||
github.com/golang-migrate/migrate/v4/source/httpfs/driver.go:127.9,133.3 1 1 | ||
github.com/golang-migrate/migrate/v4/source/httpfs/driver.go:135.16,137.3 1 0 | ||
github.com/golang-migrate/migrate/v4/source/httpfs/driver.go:142.89,144.9 2 1 | ||
github.com/golang-migrate/migrate/v4/source/httpfs/driver.go:151.2,152.16 2 1 | ||
github.com/golang-migrate/migrate/v4/source/httpfs/driver.go:155.2,155.32 1 1 | ||
github.com/golang-migrate/migrate/v4/source/httpfs/driver.go:144.9,150.3 1 1 | ||
github.com/golang-migrate/migrate/v4/source/httpfs/driver.go:152.16,154.3 1 0 | ||
github.com/golang-migrate/migrate/v4/source/httpfs/faileddriver.go:15.64,17.2 1 1 | ||
github.com/golang-migrate/migrate/v4/source/httpfs/faileddriver.go:19.38,21.2 1 1 | ||
github.com/golang-migrate/migrate/v4/source/httpfs/faileddriver.go:23.58,25.2 1 1 | ||
github.com/golang-migrate/migrate/v4/source/httpfs/faileddriver.go:27.73,29.2 1 1 | ||
github.com/golang-migrate/migrate/v4/source/httpfs/faileddriver.go:31.73,33.2 1 1 | ||
github.com/golang-migrate/migrate/v4/source/httpfs/faileddriver.go:35.93,37.2 1 1 | ||
github.com/golang-migrate/migrate/v4/source/httpfs/faileddriver.go:39.95,41.2 1 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package httpfs | ||
|
||
import ( | ||
"io" | ||
|
||
"github.com/golang-migrate/migrate/v4/source" | ||
) | ||
|
||
// failedDriver is a dummy implementation of source.Driver interface that | ||
// always returns underlying error. | ||
type failedDriver struct { | ||
err error | ||
} | ||
|
||
func (d *failedDriver) Open(url string) (source.Driver, error) { | ||
return nil, d.err | ||
} | ||
|
||
func (d *failedDriver) Close() error { | ||
return d.err | ||
} | ||
|
||
func (d *failedDriver) First() (version uint, err error) { | ||
return 0, d.err | ||
} | ||
|
||
func (d *failedDriver) Prev(version uint) (prevVersion uint, err error) { | ||
return 0, d.err | ||
} | ||
|
||
func (d *failedDriver) Next(version uint) (nextVersion uint, err error) { | ||
return 0, d.err | ||
} | ||
|
||
func (d *failedDriver) ReadUp(version uint) (r io.ReadCloser, identifier string, err error) { | ||
return nil, "", d.err | ||
} | ||
|
||
func (d *failedDriver) ReadDown(version uint) (r io.ReadCloser, identifier string, err error) { | ||
return nil, "", d.err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1 up |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1 up |
Empty file.