-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* fix(controller): always try to update status * improve check-operator resiliency * improve how the status conditions are updated * Apply suggestions from code review * Update upgrade.go * nit --------- Co-authored-by: Cedric Lamoriniere <cedric.lamoriniere@datadoghq.com>
- Loading branch information
1 parent
6f06176
commit 70db137
Showing
7 changed files
with
188 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
package v2alpha1 | ||
|
||
import ( | ||
"testing" | ||
|
||
apiutils "github.com/DataDog/datadog-operator/apis/utils" | ||
"github.com/google/go-cmp/cmp" | ||
assert "github.com/stretchr/testify/require" | ||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
func TestDeleteDatadogAgentStatusCondition(t *testing.T) { | ||
type args struct { | ||
status *DatadogAgentStatus | ||
condition string | ||
} | ||
tests := []struct { | ||
name string | ||
args args | ||
expectedStatus *DatadogAgentStatus | ||
}{ | ||
{ | ||
name: "empty status", | ||
args: args{ | ||
status: &DatadogAgentStatus{}, | ||
condition: "fooType", | ||
}, | ||
expectedStatus: &DatadogAgentStatus{}, | ||
}, | ||
{ | ||
name: "not present status", | ||
args: args{ | ||
status: &DatadogAgentStatus{ | ||
Conditions: []v1.Condition{ | ||
{ | ||
Type: "barType", | ||
}, | ||
}, | ||
}, | ||
condition: "fooType", | ||
}, | ||
expectedStatus: &DatadogAgentStatus{ | ||
Conditions: []v1.Condition{ | ||
{ | ||
Type: "barType", | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
name: "status present at the end", | ||
args: args{ | ||
status: &DatadogAgentStatus{ | ||
Conditions: []v1.Condition{ | ||
{ | ||
Type: "barType", | ||
}, | ||
{ | ||
Type: "fooType", | ||
}, | ||
}, | ||
}, | ||
condition: "fooType", | ||
}, | ||
expectedStatus: &DatadogAgentStatus{ | ||
Conditions: []v1.Condition{ | ||
{ | ||
Type: "barType", | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
name: "status present at the begining", | ||
args: args{ | ||
status: &DatadogAgentStatus{ | ||
Conditions: []v1.Condition{ | ||
{ | ||
Type: "fooType", | ||
}, | ||
{ | ||
Type: "barType", | ||
}, | ||
}, | ||
}, | ||
condition: "fooType", | ||
}, | ||
expectedStatus: &DatadogAgentStatus{ | ||
Conditions: []v1.Condition{ | ||
{ | ||
Type: "barType", | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
DeleteDatadogAgentStatusCondition(tt.args.status, tt.args.condition) | ||
assert.True(t, apiutils.IsEqualStruct(tt.args.status, tt.expectedStatus), "status \ndiff = %s", cmp.Diff(tt.args.status, tt.expectedStatus)) | ||
}) | ||
} | ||
} |
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
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