mirror of
https://github.com/go-gitea/gitea.git
synced 2024-11-22 15:14:54 +08:00
3feba9f1f4
Replace #6312 Help #5833 Wiki solution for #639
23 lines
579 B
Go
23 lines
579 B
Go
// Copyright 2024 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package perm
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestAccessMode(t *testing.T) {
|
|
names := []string{"none", "read", "write", "admin"}
|
|
for i, name := range names {
|
|
m := ParseAccessMode(name)
|
|
assert.Equal(t, AccessMode(i), m)
|
|
}
|
|
assert.Equal(t, AccessMode(4), AccessModeOwner)
|
|
assert.Equal(t, "owner", AccessModeOwner.ToString())
|
|
assert.Equal(t, AccessModeNone, ParseAccessMode("owner"))
|
|
assert.Equal(t, AccessModeNone, ParseAccessMode("invalid"))
|
|
}
|