<commit_before>//TODO: explain how to delete the image.
package bsu

import (
	"crypto/tls"
	"net/http"
	"testing"

	"github.com/hashicorp/packer/builder/osc/common"
	builderT "github.com/hashicorp/packer/helper/builder/testing"
	"github.com/outscale/osc-go/oapi"
)

func TestBuilderAcc_basic(t *testing.T) {
	builderT.Test(t, builderT.TestCase{
		PreCheck:             func() { testAccPreCheck(t) },
		Builder:              &Builder{},
		Template:             testBuilderAccBasic,
		SkipArtifactTeardown: true,
	})
}

func testAccPreCheck(t *testing.T) {
}

func testOAPIConn() (*oapi.Client, error) {
	access := &common.AccessConfig{RawRegion: "us-east-1"}
	clientConfig, err := access.Config()
	if err != nil {
		return nil, err
	}

	skipClient := &http.Client{
		Transport: &http.Transport{
			TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
		},
	}

	return oapi.NewClient(clientConfig, skipClient), nil
}

const testBuilderAccBasic = `
{
	"builders": [{
		"type": "test",
		"region": "eu-west-2",
		"vm_type": "t2.micro",
		"source_omi": "ami-65efcc11",
		"ssh_username": "outscale",
		"omi_name": "packer-test {{timestamp}}"
	}]
}<commit_msg>:chore: changed the AMI with an existing AMI to work fine with the test case<commit_after>//TODO: explain how to delete the image.
package bsu

import (
	"crypto/tls"
	"net/http"
	"testing"

	"github.com/hashicorp/packer/builder/osc/common"
	builderT "github.com/hashicorp/packer/helper/builder/testing"
	"github.com/outscale/osc-go/oapi"
)

func TestBuilderAcc_basic(t *testing.T) {
	builderT.Test(t, builderT.TestCase{
		PreCheck:             func() { testAccPreCheck(t) },
		Builder:              &Builder{},
		Template:             testBuilderAccBasic,
		SkipArtifactTeardown: true,
	})
}

func testAccPreCheck(t *testing.T) {
}

func testOAPIConn() (*oapi.Client, error) {
	access := &common.AccessConfig{RawRegion: "us-east-1"}
	clientConfig, err := access.Config()
	if err != nil {
		return nil, err
	}

	skipClient := &http.Client{
		Transport: &http.Transport{
			TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
		},
	}

	return oapi.NewClient(clientConfig, skipClient), nil
}

const testBuilderAccBasic = `
{
	"builders": [{
		"type": "test",
		"region": "eu-west-2",
		"vm_type": "t2.micro",
		"source_omi": "ami-abe953fa",
		"ssh_username": "outscale",
		"omi_name": "packer-test {{timestamp}}"
	}]
}
{'fraction_non_alphanumeric': 0.15734118636937316, 'fraction_numerical': 0.005469078670593185, 'mean_word_length': 3.964509394572025, 'pattern_counts': {'":': 14, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5881701', 'n_tokens_mistral': 918, 'n_tokens_neox': 874, 'n_words': 168}