Skip to content

Commit

Permalink
feat: debug and test models
Browse files Browse the repository at this point in the history
  • Loading branch information
net32 committed Apr 15, 2022
1 parent 782c14f commit 3e709cd
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 7 deletions.
16 changes: 16 additions & 0 deletions cmd/debug/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,24 @@ package main

import (
"fmt"

"github.com/net32/mojang-redis/server"
)

func main() {
fmt.Println("debug cmd")

// NeT32, Bar
profile, _ := server.FetchProfileByName("Bar")
fmt.Println(profile.Name, profile.UUID, profile.Properties)

profile = server.FetchProfile(profile.UUID)
fmt.Println(profile.Name, profile.UUID, profile.Properties[0].Name)

nameHistory := server.FetchNames(profile.UUID)
fmt.Println(len(nameHistory))
for i, entry := range nameHistory {
fmt.Println(i, entry.Name, entry.ChangedToAt)
}

}
38 changes: 31 additions & 7 deletions test/mojang_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,44 @@ import (
"github.com/net32/mojang-redis/server"
)

const HTTP_200_OK = 200
const HTTP_204_No_Content = 204
const HTTP_404_Not_Found = 404
const HTTP_405_Method_Not_Allowed = 405

func TestFetchProfileByName(t *testing.T) {
userName := "net32"
uuid := "c5870df744e9495f928a0e3e8703a03e"
t.Log("Testing FetchProfileByName expected", HTTP_200_OK)
profile, response := server.FetchProfileByName(userName)
if response.Code != HTTP_200_OK {
t.Errorf("Expected %d return %d", HTTP_200_OK, response.Code)
}
t.Log("Testing Profile Name expected", userName)
if profile.Name != userName {
t.Errorf("Expected %s return %s", userName, profile.Name)
}
t.Log("Testing UUID expected", uuid)
if profile.UUID != uuid {
t.Errorf("Expected %s return %s", uuid, profile.UUID)
}
t.Log("Response:", profile, response)
}

func TestUuidToNameHistory(t *testing.T) {
t.Log("Testing UuidToNameHistory expected 200")
t.Log("Testing UuidToNameHistory expected", HTTP_200_OK)
response := server.UuidToNameHistory("c5870df7-44e9-495f-928a-0e3e8703a03e")
if response.Code != 200 {
t.Error("Expected 200 return code value is", response.Code)
if response.Code != HTTP_200_OK {
t.Errorf("Expected %d return %d", HTTP_200_OK, response.Code)
}
t.Log("Response:", response)
}

func TestBlockedServers(t *testing.T) {
t.Log("Testing BlockedServers expected 200")
t.Log("Testing BlockedServers expected", HTTP_200_OK)
response := server.BlockedServers()
if response.Code != 200 {
t.Error("Expected 200 return code value is", response.Code)
if response.Code != HTTP_200_OK {
t.Errorf("Expected %d return %d", HTTP_200_OK, response.Code)
}
t.Log("Response:", response)
t.Log("Response:", response.Code, "total", len(response.Json))
}

0 comments on commit 3e709cd

Please sign in to comment.