Skip to content

Commit

Permalink
handle nil pointers
Browse files Browse the repository at this point in the history
  • Loading branch information
ejstreet committed Mar 4, 2023
1 parent dc52a95 commit 9346d2c
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions omglol/web_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ func TestGetSetRestoreWeb(t *testing.T) {
t.Errorf(err.Error())
}

if w != nil {
t.Logf("Previous content: %s", w.Content)
} else {
t.Logf("Previous content was empty.")
}

previousContent := w.Content
newContent := "this is the new content\n\nit has newlines\n"

Expand All @@ -33,12 +39,18 @@ func TestGetSetRestoreWeb(t *testing.T) {
if err != nil {
t.Errorf(err.Error())
}
if w.Content != newContent {
t.Errorf("Expected content '%s', got '%s'", newContent, w.Content)
}
if string(w.ContentBytes) != newContent {
t.Errorf("Expected ContentBytes '%s', got '%s'", newContent, string(w.Content))
}

if w != nil {
t.Logf("New content: %s", w.Content)
if w.Content != newContent {
t.Errorf("Expected content '%s', got '%s'", newContent, w.Content)
}
if string(w.ContentBytes) != newContent {
t.Errorf("Expected ContentBytes '%s', got '%s'", newContent, string(w.Content))
}
} else {
t.Errorf("GetWeb returned 'nil'.")
}

sleep()
published, err = c.SetWeb(testOwnedDomain, []byte(previousContent), true)
Expand Down

0 comments on commit 9346d2c

Please sign in to comment.