-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify and test the code base (#5)
This change drastically simplifies the layout of the code by moving all of the internal packages into either main or the tailscalesd package itself. It also improves confidence in the code by expanding test coverage from ~nothing to most of the public API code, and some small bits of the local API code. Functionally, the only change is the ability to specify the path to the local API unix socket.
- Loading branch information
Showing
13 changed files
with
963 additions
and
319 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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,44 @@ | ||
package tailscalesd | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/google/go-cmp/cmp" | ||
"inet.af/netaddr" | ||
) | ||
|
||
func TestTranslatePeerToDevice(t *testing.T) { | ||
want := Device{ | ||
Addresses: []string{ | ||
"100.2.3.4", | ||
"fd7a::1234", | ||
}, | ||
API: "localhost", | ||
Authorized: true, | ||
Hostname: "somethingclever", | ||
ID: "id", | ||
OS: "beos", | ||
Tags: []string{ | ||
"tag:foo", | ||
"tag:bar", | ||
}, | ||
} | ||
var got Device | ||
translatePeerToDevice(&interestingPeerStatusSubset{ | ||
ID: "id", | ||
HostName: "somethingclever", | ||
DNSName: "this is currently ignored", | ||
OS: "beos", | ||
TailscaleIPs: []netaddr.IP{ | ||
netaddr.MustParseIP("100.2.3.4"), | ||
netaddr.MustParseIP("fd7a::1234"), | ||
}, | ||
Tags: []string{ | ||
"tag:foo", | ||
"tag:bar", | ||
}, | ||
}, &got) | ||
if diff := cmp.Diff(got, want); diff != "" { | ||
t.Errorf("translatePeerToDevice: mismatch (-got, +want):\n%v", diff) | ||
} | ||
} |
Oops, something went wrong.