Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
fe52c88f
Commit
fe52c88f
authored
May 08, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
2e9d1053
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
0 deletions
+33
-0
go/xcommon/xnet/lonet/registry.go
go/xcommon/xnet/lonet/registry.go
+2
-0
go/xcommon/xnet/lonet/registry_sqlite_test.go
go/xcommon/xnet/lonet/registry_sqlite_test.go
+31
-0
No files found.
go/xcommon/xnet/lonet/registry.go
View file @
fe52c88f
...
...
@@ -41,6 +41,8 @@ import (
// - shared memory or file,
// - ...
type
registry
interface
{
// XXX + network name?
// Announce announces host to registry.
//
// The host is named as hostname on lonet network and is listening for
...
...
go/xcommon/xnet/lonet/registry_sqlite_test.go
View file @
fe52c88f
...
...
@@ -20,6 +20,7 @@
package
lonet
import
(
"context"
"io/ioutil"
"os"
"testing"
...
...
@@ -39,8 +40,38 @@ func TestRegistrySQLite(t *testing.T) {
r
,
err
:=
openRegistrySQLite
(
dbpath
)
X
(
err
)
// quert checks that result of Query(hostname) is as expect
//
// if expect is error - it checks that Query returns error with cause == expect.
// otherwise expect must be string and it will check that Query
// succeeds and returns osladdr == expect.
query
:=
func
(
r
*
sqliteRegistry
,
hostname
string
,
expect
interface
{})
{
// XXX ^^^ -> `r registry` (needs .Network() to get network name) ?
t
.
Helper
()
osladdr
,
err
:=
r
.
Query
(
context
.
Background
(),
hostname
)
if
cause
,
iserr
:=
expect
.
(
error
);
iserr
{
// error expected
e
,
ok
:=
err
.
(
*
registryError
)
if
!
(
ok
&&
e
.
Err
==
cause
&&
osladdr
==
""
)
{
t
.
Fatalf
(
"%s: query %q:
\n
want:
\"\"
, %v
\n
have: %q, %v"
,
r
.
uri
,
hostname
,
cause
,
osladdr
,
err
)
}
}
else
{
// !error expected
laddr
:=
expect
.
(
string
)
if
!
(
osladdr
==
laddr
&&
err
==
nil
)
{
t
.
Fatalf
(
"%s: query %q:
\n
want: %q, nil
\n
have: %q, %v"
,
r
.
uri
,
hostname
,
laddr
,
osladdr
,
err
)
}
}
}
ø
:=
errNoHost
// r.Network() == ...
// r.Query("α") == ø
query
(
r
,
"α"
,
ø
)
// r.Announce("α", "alpha:1234")
// r.Query("α") == "alpha:1234")
// r.Query("β") == ø
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment