sourcegraph/dev/src-expose/main_test.go
Keegan Carruthers-Smith 2a2a0fc6d2
src-expose: index page listing instructions and urls (#8327)
Some users (including myself) visit src-expose and get a 404. This commit
includes a useful page instead.
2020-02-07 20:27:27 +00:00

42 lines
1.2 KiB
Go

package main
import (
"testing"
"github.com/google/go-cmp/cmp"
)
func TestExplain(t *testing.T) {
wantSnapshotter := `Periodically syncing directories as git repositories to bam.
- foo/bar
- baz
`
wantAddr := `Serving the repositories at http://[::]:10810.
FIRST RUN NOTE: If src-expose has not yet been setup on Sourcegraph, then you
need to configure Sourcegraph to sync with src-expose. Paste the following
configuration as an Other External Service in Sourcegraph:
{
// url is the http url to src-expose (listening on [::]:10810)
// url should be reachable by Sourcegraph.
// "http://host.docker.internal:10810" works from Sourcegraph when using Docker for Desktop.
"url": "http://host.docker.internal:10810",
"repos": ["src-expose"] // This may change in versions later than 3.9
}
`
s := &Snapshotter{
Destination: "bam",
Dirs: []*SyncDir{{Dir: "foo/bar"}, {Dir: "baz"}},
}
if got, want := explainSnapshotter(s), wantSnapshotter; got != want {
t.Errorf("mismatch (-want +got):\n%s", cmp.Diff(want, got))
}
addr := "[::]:10810"
if got, want := explainAddr(addr), wantAddr; got != want {
t.Errorf("mismatch (-want +got):\n%s", cmp.Diff(want, got))
}
}