summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile9
-rw-r--r--xmpp/jid_test.go21
2 files changed, 27 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 2fa55ae..c6e9352 100644
--- a/Makefile
+++ b/Makefile
@@ -12,19 +12,19 @@ DESKTOP=$(BUILDDIR)/$(DESKTOP_SRC)
DESKTOP_INSTALL=$(INSTALLATION)/share/applications/$(DESKTOP_SRC)
-all: $(LIMOX) $(DESKTOP)
+all: $(LIMOX) $(DESKTOP) tests
$(BUILDDIR):
mkdir $@
-$(LIMOX): $(BUILDDIR)
+$(LIMOX): $(BUILDDIR) tests
go build -o $@ $(LIMOX_GO_PACKAGE)
$(DESKTOP): $(BUILDDIR)
cp $(DESKTOP_SRC) $@
-.PHONY: clean debug install
+.PHONY: clean debug install tests
clean:
rm -rf $(BUILDDIR)
@@ -35,3 +35,6 @@ debug:
install: $(LIMOX)
install -Dm 755 $(LIMOX) $(LIMOX_INSTALL)
install -Dm 644 $(DESKTOP) $(DESKTOP_INSTALL)
+
+tests:
+ go test ./...
diff --git a/xmpp/jid_test.go b/xmpp/jid_test.go
new file mode 100644
index 0000000..b900b9c
--- /dev/null
+++ b/xmpp/jid_test.go
@@ -0,0 +1,21 @@
+package xmpp
+
+import (
+ "testing"
+)
+
+func TestDomainpart(t *testing.T) {
+ var data = map[string]string{
+ "user@example.org/ressource": "example.org",
+ "example.org/ressource": "example.org",
+ "user@example.org": "example.org",
+ "example.org": "example.org",
+ "test.eu": "test.eu",
+ }
+
+ for k, v := range(data) {
+ if domainpart(k) != v {
+ t.Fatalf("Domain part of JID '%s' is not '%s'!", k, v)
+ }
+ }
+}