Skip to content

Commit

Permalink
Adding unit tests and updating docstrings for functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
dtaivpp committed Nov 20, 2024
1 parent 2f62b1b commit 4c40fa7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion es.go
Original file line number Diff line number Diff line change
Expand Up @@ -1803,7 +1803,7 @@ func (c *Client) RemoveIndexILMPolicy(index string) error {
return nil
}

// Function called LicenseCluster. This function takes a json document as a string which is the license to apply to the Elasticsearch cluster.
// LicenseCluster takes in the Elasticsearch license encoded as a string
func (c *Client) LicenseCluster(license string) error {
// If the license is empty, return an error
if license == "" {
Expand Down
19 changes: 19 additions & 0 deletions es_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2363,3 +2363,22 @@ func TestRemoveIndexILMPolicy(t *testing.T) {
t.Fatalf("Unexpected error. expected nil, got %s", err)
}
}
func TestLicenseCluster(t *testing.T) {
body := `{"license":{"start_date_in_millis":2728303200000,"uid":"asdfasdf-e"}}`

testSetup := &ServerSetup{
Method: "PUT",
Path: "/_license",
Body: body,
}

host, port, ts := setupTestServers(t, []*ServerSetup{testSetup})
defer ts.Close()
client := NewClient(host, port)

err := client.LicenseCluster(body)

if err != nil {
t.Errorf("Unexpected error expected nil, got %s", err)
}
}

0 comments on commit 4c40fa7

Please sign in to comment.