Invalid texture problem

So basically I am making a simple top down shooter as a learning project but I cant figure out why is SDL giving me this error.

Relevant things in main method:

   Enemy enemy(renderWindow.GetRenderer());

  renderWindow.HandleDrawing(player.rect, playerGun.rect, playerGun.sprite, playerGun.angle, playerBullet, std::move(enemy));

Enemy class:

#pragma once

#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>

#include <vector>
#include <iostream>
#include <math.h>
#include <ctime>
#include <cstdlib>

class Enemy
{
public:
    Enemy(SDL_Renderer* renderer);

    void TurnTowardsPlayer(int i, float playerX, float playerY);

    void SpawnNewEnemy();

    std::vector<float> angle;

    std::vector<float> realX;

    std::vector<float> realY;

    std::vector<int> HP;

    int maxHP = 10; 

    SDL_Rect rect;

    SDL_Texture* sprite;
private:
    float speed;

    float normalizationValue = 0.707107;
};

Enemy cpp file:

#include "include/Enemy.hpp"

#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>

#include <vector>
#include <iostream>
#include <math.h>
#include <ctime>
#include <cstdlib>

Enemy::Enemy(SDL_Renderer* renderer)
:  sprite(NULL)
{
   sprite = IMG_LoadTexture(renderer, "res/enemy.png");
   
   if(sprite = NULL)
      std::cout << "Enemy sprite failed to load, REASON: " << SDL_GetError() << std::endl;

   rect.w = 549;
   rect.h = 495;
}

void Enemy::SpawnNewEnemy()
{
   srand(time(0));
   realX.push_back(rand() % 1280);
   realY.push_back(rand() % 720);
   angle.push_back(0);
   HP.push_back(maxHP);
}

void Enemy::TurnTowardsPlayer(int i, float playerX, float playerY)
{
   angle[i] = atan2((realY[i] - playerY), (realX[i], playerY)) * (180 / 3.14159);
}

And relevant things in RenderWindow file

for(int i = 0; i < enemy.realX.size(); i++)
    {
        enemy.rect.x = std::floor(enemy.realX[i]);
        enemy.rect.y = std::floor(enemy.realY[i]);
        SDL_RenderCopyEx(renderer, enemy.sprite, NULL, &enemy.rect, enemy.angle[i], NULL, SDL_FLIP_NONE);
    }

Whats the error ?, It doesn’t look like you posted anything regarding the issue?

In the enemy constructor, there’s a if(sprite = NULL). This is setting the texture to NULL even if it was previously loaded correctly. Might be causing issues, but a more detailed description of the error would be appreciated.