-
Notifications
You must be signed in to change notification settings - Fork 269
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
opcua: add FindNamespace and tests to client
- Loading branch information
1 parent
2486dac
commit c36cc4c
Showing
2 changed files
with
67 additions
and
0 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,52 @@ | ||
//go:build integration | ||
// +build integration | ||
|
||
package uatest | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/pascaldekloe/goe/verify" | ||
|
||
"github.com/gopcua/opcua" | ||
) | ||
|
||
func TestNamespace(t *testing.T) { | ||
srv := NewServer("rw_server.py") | ||
defer srv.Close() | ||
|
||
c := opcua.NewClient(srv.Endpoint, srv.Opts...) | ||
if err := c.Connect(context.Background()); err != nil { | ||
t.Fatal(err) | ||
} | ||
defer c.Close() | ||
|
||
t.Run("NamespaceArray", func(t *testing.T) { | ||
got, err := c.NamespaceArray() | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
want := []string{ | ||
"http://opcfoundation.org/UA/", | ||
"urn:freeopcua:python:server", | ||
"http://gopcua.com/", | ||
} | ||
verify.Values(t, "", got, want) | ||
}) | ||
t.Run("FindNamespace", func(t *testing.T) { | ||
ns, err := c.FindNamespace("http://gopcua.com/") | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
if got, want := ns, uint16(2); got != want { | ||
t.Fatalf("got namespace id %d want %d", got, want) | ||
} | ||
}) | ||
t.Run("UpdateNamespaces", func(t *testing.T) { | ||
err := c.UpdateNamespaces() | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
}) | ||
} |