aboutsummaryrefslogtreecommitdiff
path: root/xmpp/component_test.go
diff options
context:
space:
mode:
authorBohdan Horbeshko <bodqhrohro@gmail.com>2022-04-01 04:42:12 +0300
committerBohdan Horbeshko <bodqhrohro@gmail.com>2022-04-01 04:42:12 +0300
commit17afd3f8c7a016d5103be949990efb695de865b5 (patch)
tree5fa9a3a0cbf418b7e4913e9aef2df3d5981030f3 /xmpp/component_test.go
parent5c238db1da48e6c1d51a3d00f6a661f99de03784 (diff)
Limit the file storage by an optional quota
Diffstat (limited to 'xmpp/component_test.go')
-rw-r--r--xmpp/component_test.go47
1 files changed, 47 insertions, 0 deletions
diff --git a/xmpp/component_test.go b/xmpp/component_test.go
new file mode 100644
index 0000000..7e7e5e7
--- /dev/null
+++ b/xmpp/component_test.go
@@ -0,0 +1,47 @@
+package xmpp
+
+import (
+ "testing"
+)
+
+func TestParseSizeGarbage(t *testing.T) {
+ _, err := parseSize("abc")
+ if err == nil {
+ t.Error("abc should not be accepted")
+ }
+}
+
+func TestParseSizeAsphalt(t *testing.T) {
+ size, err := parseSize("2B")
+ if size != 2 {
+ t.Errorf("Error parsing two bytes: %v %v", size, err)
+ }
+}
+
+func TestParseSize9K(t *testing.T) {
+ size, err := parseSize("9 KB")
+ if size != 9216 {
+ t.Errorf("Error parsing 9K: %v %v", size, err)
+ }
+}
+
+func TestParseSizeBits(t *testing.T) {
+ size, err := parseSize("9 Kb")
+ if err == nil {
+ t.Errorf("Error parsing kilobits: %v %v", size, err)
+ }
+}
+
+func TestParseSizeEB(t *testing.T) {
+ size, err := parseSize("3EB")
+ if size != 3458764513820540928 {
+ t.Errorf("Error parsing exabytes: %v %v", size, err)
+ }
+}
+
+func TestParseSizeOverflow(t *testing.T) {
+ size, err := parseSize("314EB")
+ if err == nil {
+ t.Errorf("Overflow is not overflowing: %v %v", size, err)
+ }
+}