Skip to content

Commit

Permalink
Merge pull request #5 from tukaelu/refactor/add-default-comments-disa…
Browse files Browse the repository at this point in the history
…bled

refactor: add default comments disabled
  • Loading branch information
tukaelu authored Jul 23, 2024
2 parents 4edf6be + 48141f2 commit fc81377
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ You can also explicitly specify the path using the `--config` option.
subdomain: <your zendesk subdomain>
email: <your zendesk email address>/token
token: <your zendesk token>
default_comments_disabled: true
default_locale: ja
default_permission_group_id: 123
default_user_segment_id: 456
Expand All @@ -40,6 +41,7 @@ contents_dir: path/to/contents
| subdomain | true | Specify a brand-specific subdomain |
| email | true | Specify the email address with "/token" added to the end |
| token | true | Specify your API token |
| default_comments_disabled | true | Specify the default comments disabled |
| default_locale | true | Specify the default locale for translations |
| default_permission_group_id | true | Specify the default permission group ID |
| default_user_segment_id | true | Specify the default user segment ID |
Expand Down
1 change: 1 addition & 0 deletions internal/cli/cmdEmpty.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func (c *CommandEmpty) Run(g *Global) error {

a := &zendesk.Article{
Draft: true,
CommentsDisabled: g.Config.DefaultCommentsDisabled,
Locale: c.Locale,
PermissionGroupID: c.PermissionGroupID,
SectionID: c.SectionID,
Expand Down
1 change: 1 addition & 0 deletions internal/cli/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type Config struct {
Subdomain string `yaml:"subdomain" description:"Zendesk subdomain" required:"true"`
Email string `yaml:"email" description:"Zendesk email" required:"true"`
Token string `yaml:"token" description:"Zendesk API token" required:"true"`
DefaultCommentsDisabled bool `yaml:"default_comments_disabled" description:"Default comments disabled" default:"false"`
DefaultLocale string `yaml:"default_locale" description:"Default locale for articles" required:"true"`
DefaultPermissionGroupID int `yaml:"default_permission_group_id" description:"Default permission group ID" required:"true"`
DefailtUserSegmentID int `yaml:"default_user_segment_id" description:"Default user segment ID" required:"true"`
Expand Down
10 changes: 8 additions & 2 deletions internal/cli/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package cli
import "testing"

func TestLoadConfig(t *testing.T) {
var tests = []struct {
tests := []struct {
configPath string
subdomain string
email string
token string
defaultCommentsDisabled bool
defaultLocale string
defaultPermissionGroupID int
defaultUserSegmentID int
Expand All @@ -19,6 +20,7 @@ func TestLoadConfig(t *testing.T) {
"example",
"hoge@example.com",
"foobarfoobar",
true,
"ja",
123,
456,
Expand All @@ -30,6 +32,7 @@ func TestLoadConfig(t *testing.T) {
"example",
"hoge@example.com",
"foobarfoobar",
false,
"ja",
123,
456,
Expand All @@ -56,6 +59,9 @@ func TestLoadConfig(t *testing.T) {
if g.Config.Token != tt.token {
t.Errorf("Config.Token failed: got %v, want %v", g.Config.Token, tt.token)
}
if g.Config.DefaultCommentsDisabled != tt.defaultCommentsDisabled {
t.Errorf("Config.DefaultCommentsDisabled failed: got %v, want %v", g.Config.DefaultCommentsDisabled, tt.defaultCommentsDisabled)
}
if g.Config.DefaultLocale != tt.defaultLocale {
t.Errorf("Config.DefaultLocale failed: got %v, want %v", g.Config.DefaultLocale, tt.defaultLocale)
}
Expand All @@ -76,7 +82,7 @@ func TestLoadConfig(t *testing.T) {
}

func TestConfigExists(t *testing.T) {
var tests = []struct {
tests := []struct {
name string
configPath string
notError bool
Expand Down
1 change: 1 addition & 0 deletions internal/cli/testdata/config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
subdomain: example
email: hoge@example.com
token: foobarfoobar
default_comments_disabled: true
default_locale: ja
default_permission_group_id: 123
default_user_segment_id: 456
Expand Down

0 comments on commit fc81377

Please sign in to comment.