-
Notifications
You must be signed in to change notification settings - Fork 425
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
71 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package nginx | ||
|
||
/* | ||
import ( | ||
"github.com/stretchr/testify/assert" | ||
"github.com/uber/kraken/utils/httputil" | ||
"os" | ||
"testing" | ||
) | ||
func TestRun(t *testing.T) { | ||
// Setup mock configuration parameters. | ||
params := map[string]interface{}{} | ||
// Setup Nginx config instance with minimal params for the test | ||
config := Config{ | ||
Name: "kraken-origin", // Configuration file name | ||
CacheDir: "/tmp/nginx/cache", // Cache directory for Nginx | ||
LogDir: "/tmp/nginx/logs", // Log directory for Nginx | ||
} | ||
// Optional: Setup TLS configuration for testing SSL (if needed). | ||
tlsConfig := httputil.TLSConfig{ | ||
Server: httputil.X509Pair{ | ||
Disabled: true, | ||
}, | ||
} | ||
WithTLS(tlsConfig)(&config) | ||
// Ensure necessary directories exist. | ||
err := os.MkdirAll(config.CacheDir, 0755) | ||
assert.NoError(t, err) | ||
err = os.MkdirAll(config.LogDir, 0755) | ||
assert.NoError(t, err) | ||
// Run the Nginx configuration generation and startup process. | ||
err = Run(config, params) | ||
if err != nil { | ||
t.Fatalf("Failed to run Nginx: %v", err) | ||
} | ||
// Test that the expected config file is created. | ||
configFilePath := "/tmp/nginx/test_nginx_config" | ||
_, err = os.Stat(configFilePath) | ||
assert.NoError(t, err, "Config file should be created") | ||
// Test log file creation (stdout, access log, and error log). | ||
_, err = os.Stat(config.StdoutLogPath) | ||
assert.NoError(t, err, "stdout log file should be created") | ||
_, err = os.Stat(config.AccessLogPath) | ||
assert.NoError(t, err, "access log file should be created") | ||
_, err = os.Stat(config.ErrorLogPath) | ||
assert.NoError(t, err, "error log file should be created") | ||
// Optionally test the Nginx process itself (mock or run actual Nginx). | ||
// Here you'd check if Nginx starts correctly, but this could be difficult to test | ||
// in a unit test without a running system. | ||
} | ||
*/ |