Skip to content

Commit

Permalink
feat: tests
Browse files Browse the repository at this point in the history
Signed-off-by: nabil salah <[email protected]>
  • Loading branch information
Nabil-Salah committed Aug 20, 2024
1 parent 1cba18a commit f6ad59f
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions pkg/foreman_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"os"
"path/filepath"
"testing"

"github.com/stretchr/testify/assert"
)

func TestForeman(t *testing.T) {
Expand Down Expand Up @@ -42,19 +44,24 @@ db:
)

validProcfilePath := filepath.Join(tempDir, "valid_procfile.yaml")
os.WriteFile(validProcfilePath, []byte(valid_procfile), 0644)
err := os.WriteFile(validProcfilePath, []byte(valid_procfile), 0644)
assert.NoError(t, err)

cycleProcfilePath := filepath.Join(tempDir, "cycle_procfile.yaml")
os.WriteFile(cycleProcfilePath, []byte(cycle_procfile), 0644)
err = os.WriteFile(cycleProcfilePath, []byte(cycle_procfile), 0644)
assert.NoError(t, err)

invalidCommandProcfilePath := filepath.Join(tempDir, "invalid_command_procfile.yaml")
os.WriteFile(invalidCommandProcfilePath, []byte(invalid_command_procfile), 0644)
err = os.WriteFile(invalidCommandProcfilePath, []byte(invalid_command_procfile), 0644)
assert.NoError(t, err)

invalidformedProcfilePath := filepath.Join(tempDir, "malformed_procfile.yaml")
os.WriteFile(invalidformedProcfilePath, []byte(invalid_format_procfile), 0644)
err = os.WriteFile(invalidformedProcfilePath, []byte(invalid_format_procfile), 0644)
assert.NoError(t, err)

// portConflictProcfilePath := filepath.Join(tempDir, "port_conflict_procfile.yaml")
// os.WriteFile(portConflictProcfilePath, []byte(port_conflict_procfile), 0644)
// err = os.WriteFile(portConflictProcfilePath, []byte(port_conflict_procfile), 0644)
//assert.NoError(t, err)



Expand Down Expand Up @@ -99,7 +106,7 @@ db:
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
foreman, err := InitForeman(test.procfile)
cnt := 0;
var cnt int = 0;
if err != nil {
cnt++;

Check failure on line 111 in pkg/foreman_test.go

View workflow job for this annotation

GitHub Actions / Check

ineffectual assignment to cnt (ineffassign)
if !test.expectErr {
Expand Down

0 comments on commit f6ad59f

Please sign in to comment.