@@ -28,6 +28,9 @@ func TestNewConfig(t *testing.T) {
2828 want := & Config {
2929 Context : & Context {
3030 LibrarianDir : librarianDir ,
31+ InputDir : "in" ,
32+ OutputDir : "out" ,
33+ SourceDir : "source" ,
3134 },
3235 Request : & message.Library {
3336 ID : "chronicle" ,
@@ -55,6 +58,9 @@ func TestNewConfig(t *testing.T) {
5558
5659 ctx := & Context {
5760 LibrarianDir : librarianDir ,
61+ InputDir : "in" ,
62+ OutputDir : "out" ,
63+ SourceDir : "source" ,
5864 }
5965 got , err := NewConfig (ctx )
6066 if err != nil {
@@ -65,3 +71,43 @@ func TestNewConfig(t *testing.T) {
6571 t .Errorf ("NewConfig() mismatch (-want +got):\n %s" , diff )
6672 }
6773}
74+
75+ func TestNewConfig_validate (t * testing.T ) {
76+ tests := []struct {
77+ name string
78+ context * Context
79+ }{
80+ {
81+ name : "empty librarian dir" ,
82+ context : & Context {},
83+ },
84+ {
85+ name : "empty input dir" ,
86+ context : & Context {
87+ LibrarianDir : "librarian" ,
88+ },
89+ },
90+ {
91+ name : "empty output dir" ,
92+ context : & Context {
93+ LibrarianDir : "librarian" ,
94+ InputDir : "in" ,
95+ },
96+ },
97+ {
98+ name : "empty source dir" ,
99+ context : & Context {
100+ LibrarianDir : "librarian" ,
101+ InputDir : "in" ,
102+ OutputDir : "out" ,
103+ },
104+ },
105+ }
106+ for _ , tt := range tests {
107+ t .Run (tt .name , func (t * testing.T ) {
108+ if _ , err := NewConfig (tt .context ); err == nil {
109+ t .Error ("NewConfig() error = nil, want not nil" )
110+ }
111+ })
112+ }
113+ }
0 commit comments