Skip to content

Commit

Permalink
Rig up www
Browse files Browse the repository at this point in the history
  • Loading branch information
marcopeereboom committed Apr 2, 2021
1 parent 3c76297 commit 85fead9
Show file tree
Hide file tree
Showing 8 changed files with 129 additions and 6 deletions.
1 change: 1 addition & 0 deletions politeiawww/api/comments/v1/v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const (
ErrorCodeRecordNotFound ErrorCodeT = 7
ErrorCodeRecordLocked ErrorCodeT = 8
ErrorCodePageSizeExceeded ErrorCodeT = 9
ErrorCodeLast ErrorCodeT = 10
)

var (
Expand Down
18 changes: 18 additions & 0 deletions politeiawww/api/comments/v1/v1_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) 2021 The Decred developers
// Use of this source code is governed by an ISC license that can be found in
// the LICENSE file.

package v1

import (
"testing"

"github.com/decred/politeia/unittest"
)

func TestMaps(t *testing.T) {
err := unittest.TestGenericConstMap(ErrorCodes, uint64(ErrorCodeLast))
if err != nil {
t.Fatalf("ErrorCodes: %v", err)
}
}
7 changes: 7 additions & 0 deletions politeiawww/api/records/v1/v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const (
ErrorCodeStatusChangeInvalid ErrorCodeT = 18
ErrorCodeStatusReasonNotFound ErrorCodeT = 19
ErrorCodePageSizeExceeded ErrorCodeT = 20
ErrorCodeLast ErrorCodeT = 21
)

var (
Expand Down Expand Up @@ -130,6 +131,9 @@ const (

// RecordStateVetted indicates a record has been made public.
RecordStateVetted RecordStateT = 2

// RecordStateLast unit test only.
RecordStateLast RecordStateT = 3
)

var (
Expand Down Expand Up @@ -167,6 +171,9 @@ const (
// archived record is locked from any further updates. An archived
// record have a state of either unvetted or vetted.
RecordStatusArchived RecordStatusT = 4

// RecordStatusLast unit test only.
RecordStatusLast RecordStatusT = 5
)

var (
Expand Down
26 changes: 26 additions & 0 deletions politeiawww/api/records/v1/v1_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright (c) 2021 The Decred developers
// Use of this source code is governed by an ISC license that can be found in
// the LICENSE file.

package v1

import (
"testing"

"github.com/decred/politeia/unittest"
)

func TestMaps(t *testing.T) {
err := unittest.TestGenericConstMap(ErrorCodes, uint64(ErrorCodeLast))
if err != nil {
t.Fatalf("ErrorCodes: %v", err)
}
err = unittest.TestGenericConstMap(RecordStates, uint64(RecordStateLast))
if err != nil {
t.Fatalf("RecordStates: %v", err)
}
err = unittest.TestGenericConstMap(RecordStatuses, uint64(RecordStatusLast))
if err != nil {
t.Fatalf("RecordStatuses: %v", err)
}
}
7 changes: 7 additions & 0 deletions politeiawww/api/ticketvote/v1/v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const (
ErrorCodeRecordLocked ErrorCodeT = 5
ErrorCodeTokenInvalid ErrorCodeT = 6
ErrorCodePageSizeExceeded ErrorCodeT = 7
ErrorCodeLast ErrorCodeT = 8
)

var (
Expand Down Expand Up @@ -160,6 +161,9 @@ const (
// requirements but still be rejected if it does not have the most
// net yes votes.
VoteTypeRunoff VoteT = 2

// VoteTypeLast unit test only.
VoteTypeLast VoteT = 3
)

var (
Expand Down Expand Up @@ -224,6 +228,9 @@ const (
// VoteStatusIneligible indicates that a record is not eligible to
// be voted on. This happens when a record is censored or archived.
VoteStatusIneligible VoteStatusT = 7

// VoteStatusLast unit test only.
VoteStatusLast VoteStatusT = 8
)

var (
Expand Down
26 changes: 26 additions & 0 deletions politeiawww/api/ticketvote/v1/v1_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright (c) 2021 The Decred developers
// Use of this source code is governed by an ISC license that can be found in
// the LICENSE file.

package v1

import (
"testing"

"github.com/decred/politeia/unittest"
)

func TestMaps(t *testing.T) {
err := unittest.TestGenericConstMap(ErrorCodes, uint64(ErrorCodeLast))
if err != nil {
t.Fatalf("ErrorCodes: %v", err)
}
err = unittest.TestGenericConstMap(VoteTypes, uint64(VoteTypeLast))
if err != nil {
t.Fatalf("VoteTypes: %v", err)
}
err = unittest.TestGenericConstMap(VoteStatuses, uint64(VoteStatusLast))
if err != nil {
t.Fatalf("VoteStatuses: %v", err)
}
}
20 changes: 14 additions & 6 deletions politeiawww/api/www/v1/v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ const (
ErrorStatusInvalidUserManageAction ErrorStatusT = 40
ErrorStatusUserActionNotAllowed ErrorStatusT = 41
ErrorStatusWrongVoteStatus ErrorStatusT = 42
ErrorStatusUnused1 ErrorStatusT = 43 // XXX
ErrorStatusCannotVoteOnPropComment ErrorStatusT = 44
ErrorStatusChangeMessageCannotBeBlank ErrorStatusT = 45
ErrorStatusCensorReasonCannotBeBlank ErrorStatusT = 46
Expand Down Expand Up @@ -222,6 +223,7 @@ const (
ErrorStatusTOTPInvalidType ErrorStatusT = 78
ErrorStatusRequiresTOTPCode ErrorStatusT = 79
ErrorStatusTOTPWaitForNewCode ErrorStatusT = 80
ErrorStatusLast ErrorStatusT = 81

// Proposal state codes
//
Expand All @@ -247,6 +249,7 @@ const (
PropStatusPublic PropStatusT = 4 // Proposal is publicly visible
PropStatusUnreviewedChanges PropStatusT = 5 // Proposal is not public and has unreviewed changes
PropStatusAbandoned PropStatusT = 6 // Proposal has been declared abandoned by an admin
PropStatusLast PropStatusT = 7 // Unit test only

// Proposal vote status codes
PropVoteStatusInvalid PropVoteStatusT = 0 // Invalid vote status
Expand All @@ -255,6 +258,7 @@ const (
PropVoteStatusStarted PropVoteStatusT = 3 // Proposal vote has been started
PropVoteStatusFinished PropVoteStatusT = 4 // Proposal vote has been finished
PropVoteStatusDoesntExist PropVoteStatusT = 5 // Proposal doesn't exist
PropVoteLast PropVoteStatusT = 6 // Unit test only

// Vote types
//
Expand Down Expand Up @@ -285,6 +289,7 @@ const (
UserManageUnlock UserManageActionT = 5
UserManageDeactivate UserManageActionT = 6
UserManageReactivate UserManageActionT = 7
UserManageLast UserManageActionT = 8

// Email notification types
NotificationEmailMyProposalStatusChange EmailNotificationT = 1 << 0
Expand Down Expand Up @@ -366,6 +371,7 @@ var (
ErrorStatusInvalidUserManageAction: "invalid user edit action",
ErrorStatusUserActionNotAllowed: "user action is not allowed",
ErrorStatusWrongVoteStatus: "wrong proposal vote status",
ErrorStatusUnused1: "UNUSED STATUS 1",
ErrorStatusCannotVoteOnPropComment: "cannot vote on proposal comment",
ErrorStatusChangeMessageCannotBeBlank: "status change message cannot be blank",
ErrorStatusCensorReasonCannotBeBlank: "censor comment reason cannot be blank",
Expand All @@ -383,6 +389,7 @@ var (
ErrorStatusInvalidCensorshipToken: "invalid proposal censorship token",
ErrorStatusEmailAlreadyVerified: "email address is already verified",
ErrorStatusNoProposalChanges: "no changes found in proposal",
ErrorStatusMaxProposalsExceededPolicy: "max proposals exceeded",
ErrorStatusDuplicateComment: "duplicate comment",
ErrorStatusInvalidLogin: "invalid login credentials",
ErrorStatusCommentIsCensored: "comment is censored",
Expand All @@ -406,12 +413,13 @@ var (

// PropStatus converts propsal status codes to human readable text
PropStatus = map[PropStatusT]string{
PropStatusInvalid: "invalid proposal status",
PropStatusNotFound: "not found",
PropStatusNotReviewed: "unreviewed",
PropStatusCensored: "censored",
PropStatusPublic: "public",
PropStatusAbandoned: "abandoned",
PropStatusInvalid: "invalid proposal status",
PropStatusNotFound: "not found",
PropStatusNotReviewed: "unreviewed",
PropStatusCensored: "censored",
PropStatusPublic: "public",
PropStatusUnreviewedChanges: "unreviewed changes",
PropStatusAbandoned: "abandoned",
}

// PropVoteStatus converts votes status codes to human readable text
Expand Down
30 changes: 30 additions & 0 deletions politeiawww/api/www/v1/v1_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright (c) 2021 The Decred developers
// Use of this source code is governed by an ISC license that can be found in
// the LICENSE file.

package v1

import (
"testing"

"github.com/decred/politeia/unittest"
)

func TestMaps(t *testing.T) {
err := unittest.TestGenericConstMap(ErrorStatus, uint64(ErrorStatusLast))
if err != nil {
t.Fatalf("ErrorStatus: %v", err)
}
err = unittest.TestGenericConstMap(PropStatus, uint64(PropStatusLast))
if err != nil {
t.Fatalf("PropStatus: %v", err)
}
err = unittest.TestGenericConstMap(PropVoteStatus, uint64(PropVoteLast))
if err != nil {
t.Fatalf("PropVoteStatus: %v", err)
}
err = unittest.TestGenericConstMap(UserManageAction, uint64(UserManageLast))
if err != nil {
t.Fatalf("UserManageAction: %v", err)
}
}

0 comments on commit 85fead9

Please # to comment.